I want to insert a new row in my MS Access table. When i try this code below, it gives me error on the -- myCommand.ExecuteNonQuery() -- row.
The error message is like this:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
Thanks..
Dim str As String = "Provider = Microsoft.Jet.Oledb.4.0;Data source=ALK.mdb"
Dim conn As OleDbConnection = New OleDbConnection(str)
'Open Connection
conn.Open()
Dim strCommand As String = "INSERT INTO tableTempTransaction(item_Name) VALUES('" & txtItemID.Text & "')"
Dim myCommand As OleDbCommand = New OleDbCommand(strCommand, conn)
'Execute command
myCommand.ExecuteNonQuery()
'Close connection
conn.Close()
DsTempTransaction1.Clear()
OleDbDataAdapter1.Fill(DsTempTransaction1)
The error message is like this:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
Thanks..
Dim str As String = "Provider = Microsoft.Jet.Oledb.4.0;Data source=ALK.mdb"
Dim conn As OleDbConnection = New OleDbConnection(str)
'Open Connection
conn.Open()
Dim strCommand As String = "INSERT INTO tableTempTransaction(item_Name) VALUES('" & txtItemID.Text & "')"
Dim myCommand As OleDbCommand = New OleDbCommand(strCommand, conn)
'Execute command
myCommand.ExecuteNonQuery()
'Close connection
conn.Close()
DsTempTransaction1.Clear()
OleDbDataAdapter1.Fill(DsTempTransaction1)