SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    May 2004
    Location
    jordan
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Syntax error in INSERT INTO statement


    hellow experts.
    first of all you should forgive me for my poor english.
    I am new with MS access 2003, I want to insert a record to my table, I am useing Parameters to do that. an error is always occur, the error is:
    "Syntax error in INSERT INTO statement"
    my table has 30 fields, three of the fields are date fields. and now I'm almost sure that my problem is something around that.
    please can you tell me what I need to enter date using parameters.
    my code is:
    cmd.Parameters .Add (new OleDbParameter("#"@pcal1"#",TextBox1.Text));
    cmd.Parameters .Add (new OleDbParameter("#"@pcal2"#",TextBox2.Text));
    ...
    ...
    ...
    cmd.CommandText="insert into REQUEST(REQBY,REQDATE,REQREALDATE,REQREALTIME,ROJECTID,PROJMANAGERID,OBJECT,ANOTHERDEPENDONIT,DEPENDONANOTHER,TECHNICALINT,MATERIALID,CONCERNEDPARDOM,FILIALID,EVOLUTIVE,CORRECTIVE,FUNCTIONALINT,APPLICATIONID,IMPACTONMON,IMPACTONPROC,OPERATIONFILEID,ARCHFILEID,INTIWH,INTAWH,SENSITIVE,USERSIMPACTED,USERSTEST,SERVERBOOT,EXCEPTIONALB,CONSTRAINTS,RESTOREBACKUP,OTHERPROCEDURE)values(@preqby,@pcal1,@pcal2,@prrh,@ppro,@pprom,@pob,@paidot,@ptidoan,@pti,@pmatn,@pcpd,@pfid,@pevo,@pcor,@pfi,@papn,@pimp,@picfo,@popfn,@parfn,@piwh,@pawh,@psen,@pui,@put,@psbn,@pexb,@pcidt,@preb,@poproc)";

    Please Help.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,216
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    the general form of the insert statement is
    Code:
    insert into tablename
    ( charcol
    , numcol
    , datecol 
    )
    values
    ( 'string in quotes'
    , 937
    , #2004-05-03#
    )
    make sure you have single quotes around your character values
    and hash marks around your dates
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Zealot itsyM's Avatar
    Join Date
    Jul 2002
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cupidwings

    hellow experts.
    first of all you should forgive me for my poor english.
    I am new with MS access 2003, I want to insert a record to my table, I am useing Parameters to do that. an error is always occur, the error is:
    "Syntax error in INSERT INTO statement"
    my table has 30 fields, three of the fields are date fields. and now I'm almost sure that my problem is something around that.
    please can you tell me what I need to enter date using parameters.
    my code is:
    cmd.Parameters .Add (new OleDbParameter("#"@pcal1"#",TextBox1.Text));
    cmd.Parameters .Add (new OleDbParameter("#"@pcal2"#",TextBox2.Text));
    ...
    ...
    ...
    cmd.CommandText="insert into REQUEST(REQBY,REQDATE,REQREALDATE,REQREALTIME,ROJECTID,PROJMANAGERID,OBJECT,AN OTHERDEPENDONIT,DEPENDONANOTHER,TECHNICALINT,MATERIALID,CONCERNEDPARDOM,FILIAL ID,EVOLUTIVE,CORRECTIVE,FUNCTIONALINT,APPLICATIONID,IMPACTONMON,IMPACTONPROC,O PERATIONFILEID,ARCHFILEID,INTIWH,INTAWH,SENSITIVE,USERSIMPACTED,USERSTEST,SERV ERBOOT,EXCEPTIONALB,CONSTRAINTS,RESTOREBACKUP,OTHERPROCEDURE)values(@preqby,@p cal1,@pcal2,@prrh,@ppro,@pprom,@pob,@paidot,@ptidoan,@pti,@pmatn,@pcpd,@pfid,@ pevo,@pcor,@pfi,@papn,@pimp,@picfo,@popfn,@parfn,@piwh,@pawh,@psen,@pui,@put,@ psbn,@pexb,@pcidt,@preb,@poproc)";

    Please Help.
    That's an helluva big database table you got there Check that you have typed the field names correctly. This is just a guess, but should the "ROJECTID" be "PROJECTID"?

  4. #4
    Bimbo With A Brain! silver trophy Saz's Avatar
    Join Date
    Mar 2001
    Location
    Kent, United Kingdom
    Posts
    5,275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Threads merged.
    Saz: Naturally Blonde, Naturally Dizzy!
    No longer Editor of the Community Crier.

    Don't mind me, I'm having a BLONDE moment!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •