How do you connect to SQL Server Database without using sqlclient

Editorial / Best Answer

knreddy221  

  • Nov 11th, 2006


Using System.Oledb;OledbConnection con= new OledbConnection ("Provider=SQLOLEDB.1;User Id=sa;Database=Northwind");OledbCommand cmd= new OledbCommand ("select * from table1",con);oledbdatareader dr= new oledbdatareader ();dr= cmd.ExecuteReader();datagrid1.datasource=dr;datagrid1.databind();

Showing Answers 1 - 18 of 18 Answers

Fahim

  • Nov 7th, 2006
 

You can use the methodsd and function available in the System.OleDB class instead, to get the SQL connection.

  Was this answer useful?  Yes

knreddy221

  • Nov 10th, 2006
 

Using System.Oledb;OledbConnection con= new OledbConnection ("Provider=SQLOLEDB.1;User Id=sa;Database=Northwind");OledbCommand cmd= new OledbCommand ("select * from table1",con);oledbdatareader dr= new oledbdatareader ();dr= cmd.ExecuteReader();datagrid1.datasource=dr;datagrid1.databind();

vikash agarwal

  • Nov 15th, 2006
 

using oledbnamespacesystem.data. olebd dim con as new oledbconnection(" provider=sqloledb.1;.............. ")

  Was this answer useful?  Yes

sriraja

  • Nov 19th, 2006
 

 Hi

    By oledb connection  sqlclient is called connection less oriented and

oledb is called connection oriented.

  Was this answer useful?  Yes

Kamal Kant Verma

  • Dec 18th, 2006
 

you can connect sql using oledbname space .

lata negi

  • Nov 4th, 2011
 

We have 4 Data Providers to connect to our database:
SqlClient = Used only for Sql Server database.
OracleClient = Used only for Oracle database.
Oledb = Used for any kind of databases either new or old.
Odbc = User for older databases.

So, to connect to SQL Server Database without using sqlclient, we can use OLEDB Data Provider.

Using System.Oledb;

OledbConnection conn= new OledbConnection ("Provider=SQLOLEDB.1;User Id=sa;Database=Northwind");
OledbCommand cmd= new OledbCommand ("select * from employee", conn);

Code
  1. Using System.Oledb;

  2.  

  3. OledbConnection conn= new OledbConnection ("Provider=SQLOLEDB.1;User Id=sa;Database=Northwind");

  4. OledbCommand cmd= new OledbCommand ("select * from employee", conn);

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions