Solved

Executing Querys in code

Posted on 2014-02-11
3
302 Views
Last Modified: 2014-02-11
IBDatabase1.Open;
  IBQuery1.Database := IBDatabase1;
  IBQuery1.SQL.Clear;

   //All the examples show
  //  Insert into employee(Field1, Field2) Values('1','Price')
  // Problem is that the entire string has to be in single quotes

  //None of these work
  IBQuery1.SQL.Add('Insert into Employee(PersonID, LastName) Values(1, Price)');
  IBQuery1.SQL.Add('Insert into Employee(PersonID, LastName) Values(1, "Price")');
 
  IBQuery1.Transaction.StartTransaction;
  IBQuery1.ExecSQL;

   // This generates the error - 'Dynamic SQL Error SQL Error Code = -206
   // column unknown
   // PRICE
 
 
  IBQuery1.Transaction.Commit;
  IBDatabase1.Close;
0
Comment
Question by:CiaoBaby
  • 2
3 Comments
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
ID: 39851858
You used " instead of two single quotes for each inline single quote:
IBQuery1.SQL.Add('Insert into Employee(PersonID, LastName) Values(1, ''Price'')');

Open in new window

0
 

Author Closing Comment

by:CiaoBaby
ID: 39851871
Thanks, for the fast and perfect response.  Is there some place I can find all the little gotcha's in SQL?
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 39851884
Sorry, no. This depends on the programming language used, and is no part of SQL specification.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I guess that all of us know that caching the data usually increase the performance, but I worried if all of us are aware about the risk that caching the data provides and how to minimize this.  That’s the reason why I decided to write this short art…
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now