problem with DataBase

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lian

    problem with DataBase

    hi
    Hi
    I have a problem with a dataset. Im trying to update the database but
    it doesn't updating the database
    this.oleDbConne ction1 .Open ();
    OleDbCommand cmd = new OleDbCommand ("",this.oleDbC onnection1);
    cmd.CommandText = "UPDATE Manufactor SET ,factor_Size="
    +company.manufa ctorfloor_get ()+ " WHERE player_ID='"+
    this.Session["playerID"].ToString()+"'" ;//,Finished_Produ ct="+
    this.company.fn sdprod_get () + ",Finished_Prod uct_Space="+thi s.company
    ..machine_out_p ut_get ()+ ",Machine_Num=" + this.company.ma chinenum_get
    ()
    this.oleDbDataA dapterManufacto r .UpdateCommand =cmd;
    this.lerrorlabl e .Text =this.oleDbData AdapterManufact or .Update
    (this.dsManufac tor1).ToString ();
    this.oleDbConne ction1 .Close ();
  • Peter Jausovec

    #2
    Re: problem with DataBase

    Hi,

    Does it thrown an exception ?

    I think the error is in this line (it think it should be without comma (SET
    factor_Size))
    cmd.CommandText = "UPDATE Manufactor SET ,factor_Size="


    --
    Regards,
    Peter Jausovec
    (http://blog.jausovec.net)
    "Lian" <liranby@hotmai l.com> wrote in message
    news:1a3bdfb0.0 411240245.7f1f4 51a@posting.goo gle.com...[color=blue]
    > hi
    > Hi
    > I have a problem with a dataset. Im trying to update the database but
    > it doesn't updating the database
    > this.oleDbConne ction1 .Open ();
    > OleDbCommand cmd = new OleDbCommand ("",this.oleDbC onnection1);
    > cmd.CommandText = "UPDATE Manufactor SET ,factor_Size="
    > +company.manufa ctorfloor_get ()+ " WHERE player_ID='"+
    > this.Session["playerID"].ToString()+"'" ;//,Finished_Produ ct="+
    > this.company.fn sdprod_get () + ",Finished_Prod uct_Space="+thi s.company
    > .machine_out_pu t_get ()+ ",Machine_Num=" + this.company.ma chinenum_get
    > ()
    > this.oleDbDataA dapterManufacto r .UpdateCommand =cmd;
    > this.lerrorlabl e .Text =this.oleDbData AdapterManufact or .Update
    > (this.dsManufac tor1).ToString ();
    > this.oleDbConne ction1 .Close ();[/color]


    Comment

    • Ignacio Machin \( .NET/ C#  MVP \)

      #3
      Re: problem with DataBase

      Hi,

      Try to use parameters, the thing with such a construction is that you need
      to escape the especial chars for SQL , example if
      this.company.ma chine_out_put_g et ()
      return Moe's ( very good mexican restaurant btw ) it will give you error
      as the ' will be interpreted as part of the SQL query.

      Cheers,

      --
      Ignacio Machin,
      ignacio.machin AT dot.state.fl.us
      Florida Department Of Transportation




      "Lian" <liranby@hotmai l.com> wrote in message
      news:1a3bdfb0.0 411240245.7f1f4 51a@posting.goo gle.com...[color=blue]
      > hi
      > Hi
      > I have a problem with a dataset. Im trying to update the database but
      > it doesn't updating the database
      > this.oleDbConne ction1 .Open ();
      > OleDbCommand cmd = new OleDbCommand ("",this.oleDbC onnection1);
      > cmd.CommandText = "UPDATE Manufactor SET ,factor_Size="
      > +company.manufa ctorfloor_get ()+ " WHERE player_ID='"+
      > this.Session["playerID"].ToString()+"'" ;//,Finished_Produ ct="+
      > this.company.fn sdprod_get () + ",Finished_Prod uct_Space="+thi s.company
      > .machine_out_pu t_get ()+ ",Machine_Num=" + this.company.ma chinenum_get
      > ()
      > this.oleDbDataA dapterManufacto r .UpdateCommand =cmd;
      > this.lerrorlabl e .Text =this.oleDbData AdapterManufact or .Update
      > (this.dsManufac tor1).ToString ();
      > this.oleDbConne ction1 .Close ();[/color]


      Comment

      Working...