GeekInterview.com
Series: Subject: Topic:
Question: 29 of 58

How do you connect to SQL Server Database without using sqlclient

Asked by: Interview Candidate | Asked on: Nov 7th, 2006

Editorial / Best Answer

Answered by: knreddy221

Answered On : 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();

Showing Answers 1 - 6 of 6 Answers
Fahim

Answered On : Nov 7th, 2006

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

  
Login to rate this answer.
knreddy221

Answered On : 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();

Yes  5 Users have rated as useful.
  
Login to rate this answer.
vikash agarwal

Answered On : Nov 15th, 2006

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

  
Login to rate this answer.
sriraja

Answered On : Nov 19th, 2006

 Hi

    By oledb connection  sqlclient is called connection less oriented and

oledb is called connection oriented.

  
Login to rate this answer.
Kamal Kant Verma

Answered On : Dec 18th, 2006

you can connect sql using oledbname space .

Yes  1 User has rated as useful.
  
Login to rate this answer.
lata negi

Answered On : Nov 4th, 2011

View all answers by lata negi

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);

  
Login to rate this answer.

Give your answer:

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

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Ads

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.