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.Ora cleClient.dll
Then add following lines near the using statements
using System.Data;
using System.Data.Ora cleClient;
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(o bject sender, System.EventArg s e)
{
try
{
System.Data.Ora cleClient.Oracl eConnection objConn =
new System.Data.Ora cleClient.Oracl eConnection("Da ta Source=<your db service name>;User ID='<user name>'; password='<pass word>'" );
//note that user id and password values are specified in single quotes
objConn.Open();
String strCommand;
strCommand ="Select * from <table name>";
//Create new command object
System.Data.Ora cleClient.Oracl eCommand objCommand = new System.Data.Ora cleClient.Oracl eCommand(strCom mand,objConn);
DataSet ds=new DataSet() ;
System.Data.Ora cleClient.Oracl eDataAdapter objDa = new System.Data.Ora cleClient.Oracl eDataAdapter (objCommand);
objDa.Fill(ds);
dataGrid1.DataS ource = ds;
}
catch(System.Ex ception ex)
{
MessageBox.Show (ex.Message);
}
}
HTH,
Ashutosh
"New Devil" <ib*****@islama bad-dot-net.no-spam.invalid> wrote in message news:40******** **@Usenet.com.. .
can anyone send a code for the oracle connectivity wid C#.. would be
really tahnkful ..
Desert Desperado 8)
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com