C# and oracle
I can't connect oracle with C#.I use oracle 10g,ODP.NET,VS.net2005.
I add refferrence to Oracle.DataAccess
And this is my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.client;
namespace winOra
{
public partial class frmShow : Form
{
public frmShow()
{
InitializeComponent();
}
private void btnShow_Click(object sender, EventArgs e)
{
string oradb = "Data Source=(DESCRIPTION=(ADDRESS_LIST="
+ "(ADDRESS=(PROTOCOL=TCP)(HOST=OTNSRVR)(PORT=1521)) )"
+ "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORC L)));"
+ "User Id=ebezer;Password=ebazar;";
OracleConnection conn = new OracleConnection(oradb);
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "select name from INFO where RegNo = 2003331009";
cmd.CommandType = CommandType.Text;
OracleDataReader dr = cmd.ExecuteReader();
dr.Read();
lblShow.Text = dr.GetString(0);
conn.Dispose();
}
}
}
...........................
accualy i am extremly new!
Can any one help me,Plz?
|