The following code explains how to connect to oracle db and display =
fetched data into a datagrid :o)
1. Create a winforms project and add a datagrid control on it and call =
it as datagrid1
2. Add a button control on the form and call it button1.
3. Add a reference to System.Data.OracleClient.dll
Then add following lines near the using statements
using System.Data;
using System.Data.OracleClient;
Here is the code for fetchind data from oracle table and displaying it =
in the datagrid when user clicks on the button.
private void button1_Click(object sender, System.EventArgs e)
{=20
try
{
System.Data.OracleClient.OracleConnection objConn =3D=20
new System.Data.OracleClient.OracleConnection("Data Source=3D<your =
db service name>;User ID=3D'<user name>'; password=3D'<password>'" );
//note that user id and password values are specified in single =
quotes
objConn.Open();
String strCommand;
strCommand =3D"Select * from <table name>";=20
//Create new command object
System.Data.OracleClient.OracleCommand objCommand =3D new =
System.Data.OracleClient.OracleCommand(strCommand,objConn);=20
DataSet ds=3Dnew DataSet() ;=20
System.Data.OracleClient.OracleDataAdapter objDa =3D new =
System.Data.OracleClient.OracleDataAdapter (objCommand);=20
objDa.Fill(ds);
dataGrid1.DataSource =3D ds;=20
}
catch(System.Exception ex)=20
{
MessageBox.Show (ex.Message);=20
}
}
HTH,
Ashutosh
[quoted text, click to view] "New Devil" <ibrahim@islamabad-dot-net.no-spam.invalid> wrote in message =
news:40dba1ff$4_1@Usenet.com...
> can anyone send a code for the oracle connectivity wid C#.. would be
> really tahnkful ..
> Desert Desperado 8)
>=20
>=20
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ---------------------------------------------------------- =20