Click here to Skip to main content
14,641,397 members
Rate this:
Please Sign up or sign in to vote.
See more:
Sir
I m familiar to asp.net with ms-access. but now i want to use sql server can u please help me to change the following code to sql.....
I use sql server 2000 with vs 2010..
if any change not required in any line then please also tell me...

connection string = "provider =microsoft.jet.odbc.4.0; 

Dataset ds;
      OdbcConnection cn;
     ds = new dataset();
     String st = "select * from table name";
    Odbc Data Adapter adp = new Odbc Data Adapter(st,cn);
   int r = adp.fill(ds,"abc");
   DataGrid1.Datasource =ds;
 DataGrid1.Datamember ="abc";




thank u........................
Posted
Updated 9-Mar-12 8:11am
v2

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Change the connection string.Try setting up a connection in VS with the Server Explorer pane:
1) Open Server Explorer.
2) Right click "Data connections" and select "Add connection"
3) In the dialog that follows, select your DataSource, and database, specify the security info, and press the "Test connection" button.
4) When the connection works, press "OK"
5) Highlight your database in the Server Explorer pane, and look at the Properties pane. A working example of the connection string will be shown, which you can copy and paste into your app or config file.


Replace OdbcConnection with SqlConection

Replace OdbcDataAdapter with SqlDataAdapter

You should find it works, pretty much. That code fragment should, at least.

You will probably have to add:
using System.Data.SqlClient;
At the top of your file.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100