I have played with this and been all over the place over the past 3 days. I cannot get the record to insert into the Access table. Please help me to understand what i am doing incorrectly.
VB Code:
Dim cn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\EQ2.mdb") Try cn.Open() Catch ex As Exception MsgBox("Failed to open DB") End Try Dim cmd As OleDbCommand Dim sStr As String Dim icount As Integer Try sStr = "insert into armor(ItemName, Slot)" sStr += "Values('" & name & "', '" & slot & "')" cmd = New OleDbCommand(sStr, cn) icount = cmd.ExecuteNonQuery MsgBox(icount) 'I get a 1 here Catch ex As Exception MsgBox(Err.Number & vbCrLf & Err.Description) End Try cn.Close() cn.Dispose() da.Dispose()
Or if there is a better way to insert records into an access database I am all ears.
Thank you in advance,
dminder




Reply With Quote