Solved

Executing Querys in code

Posted on 2014-02-11
3
315 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 69

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 69

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 is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
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…

773 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