Update with ADO

gra8ful10
Member Posts: 13
Hello,
I have successfully used Miklos' reading external databases with ADO to read an external SQL database from another SQL database, however when I try to change the SELECT statement:
SQLString := 'select texttest,[decimal test] as decimaltest,datetest from [Randolph EMC$testdata]';
to an UPDATE statement:
name := 'BRIAN';
number := 34.41;
SQLString := STRSUBSTNO('UPDATE [Randolph EMC$testdata] SET texttest = "%1" WHERE [decimal test] = "%2";',name,number);
I get the following error:
The call to member Execute failed. Microsoft OLE DB Driver for SQL Server returned the following message:
Invalid column name '34.41'.
What am I doing wrong? I believe it is just a formatting issue, but I have restructured the Update statement in many ways and can't figure it out.
Thanks,
Brian.
I have successfully used Miklos' reading external databases with ADO to read an external SQL database from another SQL database, however when I try to change the SELECT statement:
SQLString := 'select texttest,[decimal test] as decimaltest,datetest from [Randolph EMC$testdata]';
to an UPDATE statement:
name := 'BRIAN';
number := 34.41;
SQLString := STRSUBSTNO('UPDATE [Randolph EMC$testdata] SET texttest = "%1" WHERE [decimal test] = "%2";',name,number);
I get the following error:
The call to member Execute failed. Microsoft OLE DB Driver for SQL Server returned the following message:
Invalid column name '34.41'.
What am I doing wrong? I believe it is just a formatting issue, but I have restructured the Update statement in many ways and can't figure it out.
Thanks,
Brian.
0
Comments
-
gra8ful10 wrote:SQLString := STRSUBSTNO('UPDATE [Randolph EMC$testdata] SET texttest = "%1" WHERE [decimal test] = "%2";',name,number);
Also, it's always useful to show the SQL statement in a message box, so you could see the actual string passed to ADO.Naji Shaman
http://www.autocloseidle.com0 -
Thanks for the reply and the suggestion about the MESSAGE box, that's a good idea. I removed the quotes around %2 (which I believe is correct) and the error changed to:
Invalid column name 'BRIAN'.
Any other ideas?
Brian.0 -
Change the double quotes to single quotes. See the samples here:
http://msdn.microsoft.com/library/en-us ... z_82n9.aspNaji Shaman
http://www.autocloseidle.com0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions