password field: Syntax error in INSERT INTO statement.

Discussion in 'ASP .Net' started by Neil Zanella, Jan 23, 2005.

  1. Neil Zanella

    Neil Zanella Guest

    Hello,

    I am trying to execute ADO.NET INSERT statement where one of the
    fields
    is coming from a password HTML control. When I access the text with
    password.Value and print with Response.Write so as to check that it
    is working correctly it displays just fine. However, whenever I
    include the password field in one of the SQL INSERT statement's
    fields I get the following error:

    Exception Details: System.Data.OleDb.OleDbException: Syntax error in
    INSERT INTO statement.

    Line 85: cmd.ExecuteNonQuery();

    When I delete the password field from the insert statement things work
    fine (so the problem is no longer related to NTFS file permissions).

    Any ideas on how to solve this problem would be greatly appreciated.

    Best Regards,

    Neil
     
    Neil Zanella, Jan 23, 2005
    #1
    1. Advertising

  2. Neil Zanella

    MWells Guest

    Neil, it's difficult to pinpoint your problem without seeing some code; but
    here are a few ideas to get you started;

    If you're using a WebControls textbox (and not an HtmlControls input box),
    then the correct accessor would be something like txtPassword.Text

    Triple-check your SQL. Try modifying it so that the value you're entering
    in the textbox is manually assigned to the SqlParam (or embedded in your sql
    string, etc). That will help you debug your SQL, your schema, etc while
    removing the textbox from the equation.

    Try very simple passwords, e.g. "a". If that succeeds, you might be having
    a problem with unescaped apostrophes or something similar.

    If you can, display the generated Sql in a Trace.Write or a Response.Write,
    and copy/paste it into your Sql tool to test it manually.

    Best of luck,

    /// M


    "Neil Zanella" <> wrote in message
    news:...
    > Hello,
    >
    > I am trying to execute ADO.NET INSERT statement where one of the
    > fields
    > is coming from a password HTML control. When I access the text with
    > password.Value and print with Response.Write so as to check that it
    > is working correctly it displays just fine. However, whenever I
    > include the password field in one of the SQL INSERT statement's
    > fields I get the following error:
    >
    > Exception Details: System.Data.OleDb.OleDbException: Syntax error in
    > INSERT INTO statement.
    >
    > Line 85: cmd.ExecuteNonQuery();
    >
    > When I delete the password field from the insert statement things work
    > fine (so the problem is no longer related to NTFS file permissions).
    >
    > Any ideas on how to solve this problem would be greatly appreciated.
    >
    > Best Regards,
    >
    > Neil
     
    MWells, Jan 23, 2005
    #2
    1. Advertising

  3. Neil Zanella

    Guest

    Hello,

    Thank you for your reply. I have already tried everything
    you suggested. I also had a problem with calling
    Response.Write to debug my SQL query as
    whenever I use it the parameter holders
    which begin with @ are not substituted
    when I call Response.Write (is there
    some special method I can call on
    OleDbCommand to print the actual
    query with the parameters
    substituted in?)

    Anyways, here was my problem: as strange as
    it may sound, I renamed a field called "password"
    in MS Access to "foo" and did the same in the
    query contained in the code. I don't know how
    come but that fixed it. Is there something
    special about calling a table's field
    "password" in MS Access which
    causes the query error I was
    experiencing????

    Thanks,

    Neil
     
    , Jan 24, 2005
    #3
  4. Neil Zanella

    MWells Guest

    It might be a reserved word in Access. In Sql Server you can use most
    reserved words as column names, but you reference them in your sql using
    [brackets].

    Since you've identified it as an Access or .NET->Access issue, I'd also try
    seaching some of those newsgroups.


    <> wrote in message
    news:...
    > Hello,
    >
    > Thank you for your reply. I have already tried everything
    > you suggested. I also had a problem with calling
    > Response.Write to debug my SQL query as
    > whenever I use it the parameter holders
    > which begin with @ are not substituted
    > when I call Response.Write (is there
    > some special method I can call on
    > OleDbCommand to print the actual
    > query with the parameters
    > substituted in?)
    >
    > Anyways, here was my problem: as strange as
    > it may sound, I renamed a field called "password"
    > in MS Access to "foo" and did the same in the
    > query contained in the code. I don't know how
    > come but that fixed it. Is there something
    > special about calling a table's field
    > "password" in MS Access which
    > causes the query error I was
    > experiencing????
    >
    > Thanks,
    >
    > Neil
    >
     
    MWells, Jan 25, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. compuglobalhypermeganetz0r

    adapter update problem Syntax error in INSERT INTO statement.

    compuglobalhypermeganetz0r, Dec 8, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    848
    compuglobalhypermeganetz0r
    Dec 8, 2003
  2. Saber
    Replies:
    5
    Views:
    543
    Jo Inferis
    Jul 20, 2004
  3. jinhy82

    INSERT INTO...(password) syntax error

    jinhy82, Jun 6, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    3,569
    Hans Kesting
    Jun 6, 2005
  4. Nathan Sokalski

    SQL syntax error in INSERT INTO statement

    Nathan Sokalski, Jul 1, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    14,690
    ahmed_samir
    Sep 3, 2010
  5. Gérard Leclercq

    Syntax error in INSERT INTO statement

    Gérard Leclercq, Feb 1, 2005, in forum: ASP General
    Replies:
    6
    Views:
    226
    Bob Barrows [MVP]
    Feb 2, 2005
Loading...

Share This Page