It is true that table xyz (the target of the INSERT) is in a parent-child relationship with table abc. The PK in abc is a column RequestID_lng. The FK column in xyz is also named RequestID_lng
This is the only relationship these 2 tables are in.
I am trying to add a row in xyz with a value of 45 in the FK. There is already, previous to this action, a row in table abc with a value of 45 in the PK. So the parent already exists for this child.
I have used the watch window to copy my SQL code for the INSERT query that is being executed. I pasted that code into a new query in the Access DB and executed it without problem - it actually added the row that .Net should have.
Here is the SQL
Expand|Select|Wrap|Line Numbers
- INSERT INTO XYZ_tbl ( RequestID_lng, Result_str, Score_int, Sub1_str ) SELECT 45 AS Expr1, 'VVIRGINIA' AS Expr2, 30 AS Expr3, 'V -> VV ' AS Expr4
"provider=Microsoft.Jet.OLEDB.4.0;data source = R:\Backups\Access\MY_DB.mdb"
And the activating code
Expand|Select|Wrap|Line Numbers
- Dim ConnectionString As New OleDbConnection(strCon2)
- Dim command As New OleDbCommand(strSQL, ConnectionString)
- connectionString.Open()
- command.ExecuteNonQuery() ' error occurs here
- connectionString.Close()
Jim