I have been trying to insert a row into an access database. I have been able to insert into other tables using the same format, but this table seams to have an issue. I have dropped the table and recreated it, and that didn't seam to work. So I figured I would see if someone can see what my issue is. Here is my insert code in visual studio
Dim objcon As New ConnectString
Dim cmd As New OleDbCommand("INSERT INTO Order(OrderId, CustomerId, EmployeeId) VALUES (@OrderId, @CustomerId, @EmployeeId);", objcon.con)
With cmd.Parameters
.AddWithValue("@OrderId", CInt(txtOrderId.Text))
.AddWithValue("@CustomerId", CInt(txtCustId.Text))
.AddWithValue("@EmployeeId", CInt(txtEmployeeId.Text))
End With
objcon.con.Open()
cmd.ExecuteNonQuery()
objcon.con.Close()
The connectstring works in all my other classes, so I don't think it is the issue. The only difference in this table compared to my other tables is that it has foreign keys (customerId and EmployeeId). Can anyone see what the issue is?