This documentation is archived and is not being maintained.

OdbcConnection.Driver Property

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Gets the name of the ODBC driver specified for the current connection.

[Visual Basic]
Public ReadOnly Property Driver As String
public string Driver {get;}
public: __property String* get_Driver();
public function get Driver() : String;

Property Value

The name of the ODBC driver, which typically is the driver dynamic-link library (DLL) name (for example, Sqlsrv32.dll). The default value is an empty string ("") until the connection is opened.


Retrieving the Driver property is equivalent to calling the ODBC function SQLGetInfo with the InfoType parameter set to SQL_DRIVER_NAME.


[Visual Basic, C#, C++] The following example creates an OdbcConnection and displays the name of the specified ODBC driver.

[Visual Basic] 
Public Sub CreateOdbcConnection()
    Dim myConnString As String = _
       "DRIVER={SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=northwind;"
    Dim myConnection As New OdbcConnection(myConnString)
    MessageBox.Show("ServerVersion: " & myConnection.ServerVersion _
      & vbCrLf & "Driver: " & myConnection.Driver)
End Sub

public void CreateOdbcConnection() 
   string myConnString = "DRIVER={SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=northwind;";
   OdbcConnection myConnection = new OdbcConnection(myConnString);
   MessageBox.Show("ServerVersion: " + myConnection.ServerVersion
      + "\nDriver: " + myConnection.Driver);

    void CreateOdbcConnection()
        String* myConnString = S"DRIVER= {SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=northwind;";
        OdbcConnection* myConnection = new OdbcConnection(myConnString);
        MessageBox::Show(String::Concat(S"ServerVersion: ", myConnection->ServerVersion, S"\nDriver: ", myConnection->Driver));

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

OdbcConnection Class | OdbcConnection Members | System.Data.Odbc Namespace