
04-22-2005, 02:52 AM
|
|
Newcomer
|
|
Join Date: Apr 2005
Posts: 3
|
|
Inserting data into db gives run-time error
|
Hi everyone,
I'm trying to insert a new record but I get this message:
Run-time error '-2147467259 (80004005)':
[Maximizer][ODBC Driver][Btrieve Database]
Related_To_Id+Related_To_Number (Client_Id+Contact_Number) NOT found in table COMPANY or PEOPLE (Rcode:431) (Ecode:-4458)
Through the messagebox, the query looks like this:
INSERT INTO Related_Entries (Related_To_Id,Related_To_Number,Related_From_Id,Related_From_Number," Desc") VALUES ('040603005910960349966C','0','040603005910960349966C','2','dealer');
What happens is that whatever Related_.._Id and Related_.._Number I use, there's an automatic check if the ID's exist in either the COMPANY or PEOPLE table.
This error sais it can't find it but the ID's shown in the string ARE correct.
I manually searched the DB and they're in there.
My guess is that the problem is located elsewhere.
Here is the code:
Code:
Dim strUpdate As String
strUpdate = "INSERT INTO Related_Entries (Related_To_Id," & _
"Related_To_Number,Related_From_Id," & _
"Related_From_Number,""Desc"") " & _
"VALUES ('" & objMaxRec.GetFieldValue("IDentification") & "'," & _
"" & objMaxRec.GetFieldValue("Contact_Number") & "," & _
"'" & dgContacts.Columns(3) & "'," & _
"" & dgContacts.Columns(4) & "," & _
"'" & relationType & "');"
MsgBox strUpdate
Dim updateConnection As New adodb.Connection
updateConnection.Open "DEMElocal", "MASTER", "cheers"
Dim updateCommand As adodb.Command
Set updateCommand = New adodb.Command
With updateCommand
.ActiveConnection = updateConnection
.CommandText = strUpdate
.CommandType = adCmdText
End With
updateCommand.Execute , , adExecuteNoRecords
Thanks a lot for your time,
Ruben
|
|