?
Solved

Frustrating INSERT Error...

Posted on 2004-09-17
8
Medium Priority
?
225 Views
Last Modified: 2010-04-05
Hi,

Can any experts fin and error in the following insert statement.  I keep getting the following error but for the life of me can't find a problem.  It work find in Access...

---------------------------
Debugger Exception Notification
---------------------------
Project Application1.exe raised exception class EOleException with message 'Syntax error in INSERT INTO statement'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help  
---------------------------



  CreateUserQuery.SQL.Clear;
  QueryString := ''
    + 'INSERT INTO Users (FullName,Username,Password) VALUES ('
    + '''' + edtFullName.Text + ''''
    + ','
    + '''' + edtUsername.Text + ''''
    + ','
    + '''' + edtPassword.Text + ''''
    + ')'
    + '';
  try
    CreateUserQuery.SQL.Text := QueryString;
    CreateUserQuery.ExecSQL;
  except
    on e: exception do
      ShowMessage('Error :' + E.message);
  end;

Hope you can help.

Bego.

0
Comment
Question by:begonz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 12083216
CreateUserQuery.SQL.Clear;
  QueryString := ''
    + 'INSERT INTO Users (FullName,Username,Password) VALUES ('
    + QuotedStr( edtFullName.Text)+','
    + QuotedStr(edtUsername.Text)+','
    + QuotedStr(edtPassword.Text )+')';
  try
    CreateUserQuery.SQL.Text := QueryString;
    CreateUserQuery.ExecSQL;
  except
    on e: exception do
      ShowMessage('Error :' + E.message);
  end;

F68 ;-)
0
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 12083232
sorry, posted too early

this one is corrected
...
QueryString := 'INSERT INTO Users (FullName,Username,Password) VALUES ('
    + QuotedStr( edtFullName.Text)+','
    + QuotedStr(edtUsername.Text)+','
    + QuotedStr(edtPassword.Text )+')';
...
0
 

Author Comment

by:begonz
ID: 12089443
Sorry, same problem....  As soon is it executes CreateUserQuery.ExecSQL; the error appears.  Anymore help?????

Thanks.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 12089455
So there's something that come from the edit fields....are you sure about the values passed by them?
0
 
LVL 5

Expert Comment

by:tzxie2000
ID: 12089748
how about test AnsiQuotedStr ?
QueryString := 'INSERT INTO Users (FullName,Username,Password) VALUES ('
    + AnsiQuotedStrr( edtFullName.Text)+','
    + AnsiQuotedStr(edtUsername.Text)+','
    + AnsiQuotedStr(edtPassword.Text )+')';

if still error
you can set a point before
CreateUserQuery.SQL.Text := QueryString;
and add a watch about CreateUserQuery.SQL.Text
and paste the value in watch in the comment
this will let us more easy to determine the questioon
0
 
LVL 10

Accepted Solution

by:
Jacco earned 500 total points
ID: 12090685
In some database systems USERNAME, PASSWORD might be reserved words. If they are used as fields in tables some RDBMSs have special quote chars to allow using them.

Microsoft SQL Server for example allow for there use if you squarebrace them.

QueryString :=  'INSERT INTO Users (FullName,[Username],[Password]) VALUES ('

I am not sure how other RDBMSs so this.

Regards Jacco
0
 
LVL 46

Expert Comment

by:aikimark
ID: 12093748
try:
QueryString :=  'INSERT INTO [Users] ... '
0
 

Author Comment

by:begonz
ID: 12107594
Thanks Jacco, all working now, can't believe it was that simple!  
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

777 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