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
[C#]
public string Driver {get;}
[C++]
public: __property String* get_Driver();
[JScript]
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.

Remarks

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

Example

[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)
    myConnection.Open()
    MessageBox.Show("ServerVersion: " & myConnection.ServerVersion _
      & vbCrLf & "Driver: " & myConnection.Driver)
    myConnection.Close()
End Sub

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

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

[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.

Requirements

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

Show: