Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module DatabaseConnectionsModule
- Public con As New OleDb.OleDbConnection
- Public Const dbProvider As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
- Public dbSource As String = "Data Source = " & Application.StartupPath.Substring(0, Application.StartupPath.Length - 9) & "Access\" & "Simple.mdb"
- Public ds As New DataSet
- Public da As OleDb.OleDbDataAdapter
- Public sql As String = "select * from myTable"
- Sub ConnectToDatabase(ByVal strSQL As String, ByVal strTable As String)
- 'Connect to
- con.ConnectionString = dbProvider & dbSource
- con.Open()
- 'This takes the data from the Access table and puts it into the form
- 'It will show the first record in the form
- da = New OleDb.OleDbDataAdapter(strSQL, con)
- da.Fill(ds, strTable)
- con.Close()
- End Sub
- Sub DisconnectFromDatabase()
- 'clear the dynaset
- ds.Clear()
- con.Close()
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement