data source1
After specifying the provider, an important factor is the name of the database you want to connect to.After specifying the provider, an important factor is the name of the database you want to connect to.
Dim oleConn As System.Data.OleDb.OleDbConnection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
oleConn=NewSystem.Data.OleDb.OleDbConnection
("Provider=Microsoft.JET.OLEDB.4.0;"
& "Data Source=C:\Programs\Exercise.mdb;")
End Sub
(or)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
oleConn=NewSystem.Data.OleDb.OleDbConnection
("Provider=Microsoft.JET.OLEDB.4.0;"
& "Data Source=C:\Programs\Exercise.mdb;")
End Sub
(or)
If you had declared an OleDbConnection variable using the other constructor, to specify the data source, you can include its section in the connectionString argument of the constructor. Here is an example:
Dim oleConn As System.Data.OleDb.OleDbConnection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
oleConn = New System.Data.OleDb.OleDbConnection
oleConn.ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;" &
"Data Source=C:\Programs\Exercise.mdb;"
End Sub
If the connection has already been established and the data source was specified, to know the name of the data source, you can get the value of the OleDbConnection.DataSource property.
Labels: LANGUAGE .NET
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home