Friday 26 October 2012

Connet C#.net with SQL server 2008 with dsn

Hi. Guys,
   Create a dsn with name "dsnApp".

Add  following code to your program.cs file


         try
            {
               OdbcConnection conDb=new OdbcConnection();
                string strsql ;
                strsql = "Provider=MSDASQL.1;DSN=dsnApp;UID=sa;pwd=app;";
                conDb.ConnectionString = strsql;
                conDb.Open();
           }
            catch(Exception ex)
           {
               MessageBox.Show(ex.ToString());
            }
                                                                                 If you are using VB.net your code is here

Thank you :)