Clarification on .NET (VB 2005 Express edition) I am trying to create a program to insert / update records in MS Access DB. I tried to check the MSDN, forums and somehow getting there. It looks so easy, but tough. I get strange error when I execute the connection.open command :(
The error I get is
"A first chance exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll"
Below is the function.
Public Sub InsertRow(ByVal connectionString As String, _
ByVal insertSQL As String)
Using connection As New OleDbConnection(connectionString)
' The insertSQL string contains a SQL statement that
' inserts a new row in the source table.
Dim command As New OleDbCommand(insertSQL)
' Set the Connection to the new OleDbConnection.
command.Connection = connection
' Open the connection and execute the insert command.
Try connection.Open()
command.ExecuteNonQuery()
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
' The connection is automatically closed when the
' code exits the Using block.
End Using
End Sub
Any helps? |