Solved

Frustrating INSERT Error...

Posted on 2004-09-17
8
220 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
8 Comments
 
LVL 22

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 22

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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 22

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 125 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 45

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

770 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