SitePoint Sponsor

User Tag List

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

    Unhappy PLEASE HEEEEELP, syntax error in insert statment

    Hi experts,

    I'm realy looking for an expert to help.
    some experts told me that I have to use ( # , ' ), but I'm realy confused . I dont know where I shoud these, am I suposed to use them in the insert statment or in the parameters.
    here is my code if someone woud like to help.
    again I am very sorry for my poor english.


    private void Button1_Click(object sender, System.EventArgs e)
    {
    OleDbCommand cmd = new OleDbCommand();
    cmd.Connection =conn2;
    cmd.CommandText ="insert into REQUEST(REQBY,REQDATE,REQREALDATE,REQREALTIME,PROJECTID,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)";

    cmd.Parameters.Add (new OleDbParameter( " @pcal1 " ,TextBox1.Text));
    cmd.Parameters.Add (new OleDbParameter( " @pcal2 " ,TextBox2.Text));

    cmd.Parameters.Add (new OleDbParameter("@preqby",ddl1.SelectedValue));
    cmd.Parameters.Add (new OleDbParameter("@ppro",ddl2.SelectedValue));
    cmd.Parameters.Add (new OleDbParameter("@pprom",ddl3.SelectedValue));
    cmd.Parameters.Add (new OleDbParameter("@pmatn",ddl4.SelectedValue));
    cmd.Parameters.Add (new OleDbParameter("@papn",ddl5.SelectedValue));
    cmd.Parameters.Add (new OleDbParameter("@popfn",ddl6.SelectedValue));
    cmd.Parameters.Add (new OleDbParameter("@parfn",ddl7.SelectedValue));
    cmd.Parameters.Add (new OleDbParameter("@pfid",ddl8.SelectedValue));

    cmd.Parameters.Add (new OleDbParameter( " @prrh " ,TextBox9.Text));
    cmd.Parameters.Add (new OleDbParameter("@pob",TextBox5.Text));
    cmd.Parameters.Add (new OleDbParameter("@paidot",TextBox6.Text));
    cmd.Parameters.Add (new OleDbParameter("@pcpd",TextBox13.Text));
    cmd.Parameters.Add (new OleDbParameter("@pcidt",TextBox16.Text));
    cmd.Parameters.Add (new OleDbParameter("@poproc",TextBox3.Text));
    cmd.Parameters.Add (new OleDbParameter("@ptidoan",TextBox7.Text));

    cmd.Parameters.Add (new OleDbParameter("@pti",CheckBox1.Checked));
    cmd.Parameters.Add (new OleDbParameter("@pfi",CheckBox2.Checked));
    cmd.Parameters.Add (new OleDbParameter("@pevo",CheckBox3.Checked));
    cmd.Parameters.Add (new OleDbParameter("@piwh",CheckBox4.Checked));
    cmd.Parameters.Add (new OleDbParameter("@pcor",CheckBox5.Checked));
    cmd.Parameters.Add (new OleDbParameter("@pimp",CheckBox6.Checked));
    cmd.Parameters.Add (new OleDbParameter("@picfo",CheckBox8.Checked));
    cmd.Parameters.Add (new OleDbParameter("@pawh",CheckBox10.Checked));
    cmd.Parameters.Add (new OleDbParameter("@psen",CheckBox11.Checked));
    cmd.Parameters.Add (new OleDbParameter("@pui",CheckBox12.Checked ));
    cmd.Parameters.Add (new OleDbParameter("@put",CheckBox13.Checked ));
    cmd.Parameters.Add (new OleDbParameter("@psbn",CheckBox14.Checked));
    cmd.Parameters.Add (new OleDbParameter("@pexb",CheckBox15.Checked));
    cmd.Parameters.Add (new OleDbParameter("@preb",CheckBox21.Checked));
    cmd.ExecuteNonQuery();
    DataBind();
    conn2.Close ();
    }

    please note that @pcal1,@pcal2 and @prrh will store DATE. and I think that my error is around that.

    thank god, we have peoble like you.

  2. #2
    SitePoint Member RedLionTech_BMA's Avatar
    Join Date
    May 2004
    Location
    Richmond, VA
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What problem are you encountering?

  3. #3
    SitePoint Addict
    Join Date
    Dec 2002
    Location
    Gent, Belgium, Europe, World, Univers
    Posts
    397
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cmd.Parameters.Add (new OleDbParameter( " @pcal1 " ,TextBox1.Text));

    " @pcal1 "

    You have spaces between the " and the name of your parameter .. Is that supposed to be ?

    And euh ... Shouldn't you store the actual query in a stored procedure ? This way, you can as well just execute a query ... :s


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
  •