The Database Provider
The first parameter or one of the parameters of a connection is the database provider. To specify the provider, you create its section with:
Provider=ProviderValue;
There are various providers available. The one used for Microsoft Access is:
Microsoft.Jet.OLEDB.4.0
If you had declared an OleDbConnection variable using the default constructor, to specify the provider, you can include a "Provider=Microsoft.Jet.OLEDB.4.0;" string to your OleDbConnection.ConnectionString property.
Here is an example:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadDim oleConn As System.Data.OleDb.OleDbConnection
oleConn = New System.Data.OleDb.OleDbConnection oleConn.ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;"
End Sub
| If you are using an OleDbConnection variable declared using the second constructor, you can include the provider in the connectionString argument of the constructor. Here is an example: |
Dim oleConn As System.Data.OleDb.OleDbConnection
oleConn=NewSystem.Data.OleDb.OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;")
Sub
| If the connection was already established and you want to find out what provider it is using, you can get the value of the OleDbConnection.Provider property. Here is an example: |
oleConn=NewSystem.Data.OleDb.OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;") End Sub Private Sub btnEnquire_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnquire.Click
Dim strProvider As String = oleConn.Provider MsgBox(strProvider)
End Sub
Labels: LANGUAGE .NET

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home