Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private class AdminDatabase
- ' stores the connection string which is set in the New() method
- dim strAdminConnection as string
- public sub New()
- ...
- adminName = dlgopen.FileName
- conAdminDB = New OleDbConnection
- conAdminDB.ConnectionString = "Data Source='" + adminName + "';" + _
- "Provider=Microsoft.ACE.OLEDB.12.0"
- ' store the connection string in strAdminConnection
- strAdminConnection = conAdminDB.ConnectionString.ToString()
- My.Settings.SetUserOverride("AdminConnectionString", strAdminConnection)
- ...
- End Sub
- ' retrieves data from the database
- Public Function getDataTable(ByVal sqlStatement As String) As DataTable
- Dim ds As New DataSet
- Dim dt As New DataTable
- Dim da As New OleDbDataAdapter
- Dim localCon As New OleDbConnection
- localCon.ConnectionString = strAdminConnection
- Using localCon
- Dim command As OleDbCommand = localCon.CreateCommand()
- command.CommandText = sqlStatement
- localCon.Open()
- da.SelectCommand = command
- da.Fill(dt)
- getDataTable = dt
- End Using
- End Function
- End Class
Add Comment
Please, Sign In to add comment