Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Data.OleDb
- Module Module1
- Public dbPath As String = Application.StartupPath & "\PayrollCortez.accdb"
- Public connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & dbPath
- Public Function perfromQuery(ByVal connectionsString As String, ByVal sqlCommand As String) As OleDb.OleDbDataAdapter
- Dim dbConnection As OleDbConnection
- Dim dbCommand As New OleDbCommand()
- Dim dbDataReader As OleDb.OleDbDataAdapter = Nothing
- Try
- dbConnection = New OleDbConnection(connectionsString)
- dbCommand.CommandText = sqlCommand
- dbCommand.Connection = dbConnection
- dbConnection.Open()
- dbDataReader = dbCommand.ExecuteReader
- Return dbDataReader
- dbConnection.Close()
- Catch ex As Exception
- MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
- End Try
- Return Nothing
- End Function
- Public Function performNonQuery(ByVal connectionString As String, ByVal sqlCommand As String) As Boolean
- Dim dbConnection As OleDbConnection
- Dim dbCommand As New OleDbCommand()
- Try
- dbConnection = New OleDbConnection(connectionString)
- dbCommand.CommandText = sqlCommand
- dbCommand.Connection = dbConnection
- dbCommand.Connection.Open()
- dbCommand.ExecuteNonQuery()
- dbConnection.Close()
- Catch ex As Exception
- End Try
- Return True
- End Function
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement