Insert New Row into Table (VB 2005)
hi..i'm trying to insert a new row into table, but it always fail.
this is my code :
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
strSQL2 = "INSERT INTO HISTORY VALUES ('" & txt01.Text & "'," & _
" '" & txt02.Text & "'," & _
" '" & txt03.Text & "'," & _
" '" & txt04.Text & "'," & _
" '" & txt05.Text & "'," & _
" '" & txt06.Text & "'," & _
" '" & txt07.Text & "'," & _
" '" & txt08.Text & "'," & _
" '" & txt09.Text & "'," & _
" '" & txt10.Text & "'," & _
" '" & txt11.Text & "'," & _
" '" & txt12.Text & "'," & _
" '" & txt13.Text & "')"
Con.ConnectionString = "Provider = microsoft.jet.oledb.4.0; data source = c:\Event2.mdb"
Com2 = New OleDb.OleDbCommand(strSQL2, Con)
Con.Open()
Try
result = Com.ExecuteNonQuery()
If (result > 0) Then
MsgBox("Success")
End If
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
If Com IsNot Nothing Then Com.Dispose()
Con.Close()
End Sub
Please i need your help, please correct my code.
in advance, thank you very much for your help.
|