My code is
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strConn As String
Dim strSQL As String
Dim Conn As OleDb.OleDbConnection
Dim cmd As OleDb.OleDbCommand
Label1.Visible = False
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\db2.mdb;" & _
"User ID=Admin;" & _
"Password="
'Pass the Connection string to OleDbConnection object.
Conn = New OleDb.OleDbConnection(strConn)
cmd = New OleDb.OleDbCommand(strSQL, Conn)
Conn.Open()
'Build the SQL strings.
strSQL = "insert into table1 values( 99,'sad')"
Try
cmd.ExecuteNonQuery()
Catch ex As OleDb.OleDbException
Label1.Visible = True
Label1.Text = ex.ToString
End Try
Conn.Close()
End Sub
The database table is table1 in db1.mdb.
the error occurs at cmd.ExecuteNonQuery()
could anyone help me . please!
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strConn As String
Dim strSQL As String
Dim Conn As OleDb.OleDbConnection
Dim cmd As OleDb.OleDbCommand
Label1.Visible = False
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\db2.mdb;" & _
"User ID=Admin;" & _
"Password="
'Pass the Connection string to OleDbConnection object.
Conn = New OleDb.OleDbConnection(strConn)
cmd = New OleDb.OleDbCommand(strSQL, Conn)
Conn.Open()
'Build the SQL strings.
strSQL = "insert into table1 values( 99,'sad')"
Try
cmd.ExecuteNonQuery()
Catch ex As OleDb.OleDbException
Label1.Visible = True
Label1.Text = ex.ToString
End Try
Conn.Close()
End Sub
The database table is table1 in db1.mdb.
the error occurs at cmd.ExecuteNonQuery()
could anyone help me . please!