Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
Pls help me Thanks in Advance..Pls pls
Error:- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key,software,antivirus,scanner,printer,ups,otheritem,createdby,createdon)values(' at line 1
 
 pcperforma pc = new pcperforma(0, Session["refguid"].ToString(), Convert.ToInt32(ddldept.SelectedValue), txtname.Text, txtmobileno.Text, ddlpc.SelectedValue, txtcpu.Text, txtmotherboard.Text, txtram.Text, txtharddisk.Text, txtdvdwriter.Text, txtcabinet.Text, txtsmps.Text, txtkeyboard.Text, txtmouse.Text, txtgraphiccard.Text, txtmacid.Text, txtlancardip.Text, txtlcdmoniter.Text, ddlwindows.SelectedValue, txtwindowkey.Text, txtsoftware.Text, txtantivirus.Text, txtscanner.Text, txtprinter.Text, txtups.Text, txtotheritems.Text, crtby);
                    pc.CreatePcPerforma(con, tran);
 
And The Calling Function is:-
 
public bool CreatePcPerforma(MySqlConnection con, MySqlTransaction tran)
    {
        int r = 0;
        try
        {
            string qry = "insert into pcdetails(refid,deptnameid,username,mobileno,pc,cpu,motherboard,ram,harddisk,dvdwriter,cabinet,smps,keyboard,mouse,graphiccard,macid,ip,monitor,window,key,software,antivirus,scanner,printer,ups,otheritem,createdby,createdon)values(@refid,@deptnameid,@username,@mobileno,@pc,@cpu,@motherboard,@ram,@harddisk,@dvdwriter,@cabinet,@smps,@keyboard,@mouse,@graphiccard,@macid,@ip,@monitor,@window,@key,@software,@antivirus,@scanner,@printer,@ups,@otheritem,@createdby,now())";
            MySqlParameter refidP = new MySqlParameter("@refid", RefId);
            MySqlParameter deptnameidP = new MySqlParameter("@deptnameid", DeptNameId);
            MySqlParameter usernameP = new MySqlParameter("@username", UserName);
            MySqlParameter mobilenoP = new MySqlParameter("@mobileno", MobNo);
            MySqlParameter pcP = new MySqlParameter("@pc", PC);
            MySqlParameter cpuP = new MySqlParameter("@cpu", CPU);
            MySqlParameter motherboardP = new MySqlParameter("@motherboard", MotherBoard);
            MySqlParameter ramP = new MySqlParameter("@ram", RAM);
            MySqlParameter harddiskP = new MySqlParameter("@harddisk", HardDisk);
            MySqlParameter dvdwriterP = new MySqlParameter("@dvdwriter", DvdWriter);
            MySqlParameter cabinetP = new MySqlParameter("@cabinet", Cabinet);
            MySqlParameter smpsP = new MySqlParameter("@smps", SMPS);
            MySqlParameter keyboardP = new MySqlParameter("@keyboard", Keyboard);
            MySqlParameter mouseP = new MySqlParameter("@mouse", Mouse);
            MySqlParameter graphiccardP = new MySqlParameter("@graphiccard", GraphicCard);
            MySqlParameter macidP = new MySqlParameter("@macid", MacIp);
            MySqlParameter ipP = new MySqlParameter("@ip", IP);
            MySqlParameter monitorP = new MySqlParameter("@monitor", Monitor);
            MySqlParameter windowP = new MySqlParameter("@window", Window);
            MySqlParameter keyP = new MySqlParameter("@key", Key);
            MySqlParameter softwareP = new MySqlParameter("@software", Software);
            MySqlParameter antivirusP = new MySqlParameter("@antivirus", Antivirus);
            MySqlParameter scannerP = new MySqlParameter("@scanner", Scanner);
            MySqlParameter printerP = new MySqlParameter("@printer", Printer);
            MySqlParameter upsP = new MySqlParameter("@ups", UPS);
            MySqlParameter otheritemP = new MySqlParameter("@otheritem", OtherItem);
            MySqlParameter createdbyP = new MySqlParameter("@createdby", CreatedBy);
            MySqlParameter[] p = { refidP, deptnameidP,usernameP,mobilenoP,pcP,cpuP,motherboardP,ramP,harddiskP,dvdwriterP,cabinetP,smpsP,keyboardP,mouseP,graphiccardP,
                                 macidP,ipP,monitorP,windowP,keyP,softwareP,antivirusP,scannerP,printerP,upsP,otheritemP,createdbyP};
            r = common.ExecuteNonQuery(con, tran, qry, p);
            if (r > 0)
            {
                return true;
            }
            else
            {
                Exception xp = new Exception("Create Personal Computer Description  Error.");
                throw xp;
            }
        }
        catch
        {
            Exception ex = new Exception("Create Personal Computer Description Error.");
            throw ex;
        }
    }
Posted 6-Dec-12 17:03pm
Edited 6-Dec-12 17:04pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Don't use column name 'KEY'. It is a reserved word
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,532
1 OriginalGriff 5,976
2 CPallini 2,473
3 Richard MacCutchan 1,687
4 Abhinav S 1,550


Advertise | Privacy | Mobile
Web03 | 2.8.140821.2 | Last Updated 7 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100