Connect to SqlServer using OdbcConnection : ODBC « ADO.Net « C# / CSharp Tutorial






using System;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Data.Odbc;


    class Program
    {
        static void Main(string[] args)
        {

            string odbcConnectString = "Driver={SQL Native Client};" +
                "Server=(local);Database=AdventureWorks;uid=sa;pwd=password;";

            using (OdbcConnection connection =new OdbcConnection(odbcConnectString))
            {
                connection.Open(  );
                Console.WriteLine("ConnectionString = {0}\n", odbcConnectString);
                Console.WriteLine("State = {0}", connection.State);
                Console.WriteLine("DataSource = {0}", connection.DataSource);
                Console.WriteLine("ServerVersion = {0}", connection.ServerVersion);
            }
        }
    }








32.48.ODBC
32.48.1.Creating Connection To ODBC
32.48.2.Connecting to a Text File
32.48.3.Connecting to an ODBC Data Source
32.48.4.Connect to SqlServer using OdbcConnection
32.48.5.Odbc Provider