hi, i have got some problems in MS access 2007..
1) i cannot send the data which the user key in into the textbox of VB2008.
2) the Access file is not updating
3) how can i know(confirm) that the data has been saved or there is an error in it..
4) when i insert 'cmd.ExecuteNonQuery()' there is an error which state "You cannot add or change a record because a related record is required in table 'Code'."
i do not know which part of my code is giving me problems..
pls help..
thanks
buz
this is my coding:
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\user\Desktop\Baxter\BaxterOCR_new.mdb;Jet OLEDB:Database Password=12345;"
Dim MySQL As String = "INSERT INTO Batch" & _
"(BatchNo, BarCodeNo, OperatorID, CodeNo,ExpiryDate) VALUES " & "('" & txtBatchNo.Text & "','" & txtBarCodeNo.Text & "','" & txtOperatorID.Text & "','" & txtCodeno.Text & "','" & txtExpiryDate.Text & "')"
Dim MyConn As New OleDbConnection(strConn)
Dim cmd As New OleDbCommand(MySQL, MyConn)
MyConn.Open()
With cmd.Parameters
.Add(New OleDbParameter("@BatchNo", txtBatchNo.Text))
.Add(New OleDbParameter("@BarCodeNo", txtBarCodeNo.Text))
.Add(New OleDbParameter("@OperatorID", txtOperatorID.Text))
.Add(New OleDbParameter("@CodeNo", txtCodeno.Text))
.Add(New OleDbParameter("@ExpiryDate", txtExpiryDate.Text))
End With
cmd.ExecuteNonQuery()
MyConn.Close()
End Sub