How to get oledb connection?

Answer Posted / senthil kumar

using OLEDB connection we can connect the MS-ACCESS,Sql
Server,Oracle.

here i given the coding for connect the oledb connection

OleDbConnection con = new OleDbConnection();
con.ConnectionString="Provider=Microsoft.Jet.OleDb.4.0;Data
Source=databasenamewithpath;";
con.Open();

then u can use the dataset or datareader
OleDbCommand cmd = new OleDbCommand(sql,con);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();


OleDbDataReader reader;
reader = cmd.ExecuteReader();


OleDbDataAdapter oda = new OleDbDataAdapter(sql,con);
DataSet ds = new DataSet();
oda.Fill(ds,"tablename");

i hope that these are enough.

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define table relations?

559


What is shadow copy?

581


Explain the basic use of "dataview" and explain its methods.

533


What is difference between Dataview and Datatable?

530


What is executequery?

496






What is the executescalar method?

584


Give an example that shows how to execute a stored procedure in ado.net?

571


How can we add relation between tables in a dataset?

547


What is Data Provider?

570


What are the objects of ado.net?

537


Explain the dataadapter class in ado.net?

663


What is the return type of executescalar?

495


What are the methods of XML dataset object?

615


What are the different ado.net namespaces?

626


What is datasource in ado.net?

590