Export (0) Print
Expand All

OdbcConnection Constructor

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

Initializes a new instance of the OdbcConnection class.

Overload List

Initializes a new instance of the OdbcConnection class.

[Visual Basic] Public Sub New()
[C#] public OdbcConnection();
[C++] public: OdbcConnection();
[JScript] public function OdbcConnection();

Initializes a new instance of the OdbcConnection class with the specified connection string.

[Visual Basic] Public Sub New(String)
[C#] public OdbcConnection(string);
[C++] public: OdbcConnection(String*);
[JScript] public function OdbcConnection(String);

Example

[Visual Basic, C#, C++] The following example creates and opens an OdbcConnection.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of the OdbcConnection constructor. For other examples that might be available, see the individual overload topics.
[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()
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();
}

[C++] 
public:
    void CreateOdbcConnection()
    {
        String* myConnString = S"DRIVER= {SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=northwind;";
        OdbcConnection* myConnection = new OdbcConnection(myConnString);
        myConnection->Open();
    };

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

See Also

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

Show:
© 2015 Microsoft