Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > Inserting data into db gives run-time error


Reply
 
Thread Tools Display Modes
  #1  
Old 04-22-2005, 02:52 AM
Ruben Ruben is offline
Newcomer
 
Join Date: Apr 2005
Posts: 3
Exclamation 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
Reply With Quote
  #2  
Old 04-22-2005, 04:04 PM
MKoslof's Avatar
MKoslof MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

Welcome to the forum.

What database are you working? I see you are dealing with Btrieve data types, but what Database engine are you trying to insert into? And why are there double quotes around the DESC field?
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
  #3  
Old 04-24-2005, 02:07 AM
Ruben Ruben is offline
Newcomer
 
Join Date: Apr 2005
Posts: 3
Default

I'm working with the pervasive data-engine.
There are double quotes around desc because it is a reserved word.
To make it count as a table name instead of a reserved word I have to put double quotes around it.
(I tested this already and worked in another program)

Thanks a lot for your reply already.

Cheers,
Ruben.
Reply With Quote
  #4  
Old 04-25-2005, 05:03 AM
Ruben Ruben is offline
Newcomer
 
Join Date: Apr 2005
Posts: 3
Default

No one with an idea?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->