SqlDataAdapter

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

    SqlDataAdapter

    Hi
    Im using SqlDataAdapter

    when i run ad.update()
    Its Inserting Rows when it should be updatings

    Here is my code...what is wrong here

    this.oAdapter.S electComand = new SqlCommand("sel ect top 0 from Users")
    // just to create the commands update, insert
    SqlCommandBuild er oCmd = new SqlCommandBuild er(this.oAdapte r)
    this.oAdapter.U pdateCommand = oCmd.GetUpdateC ommand();
    this.oAdapter.U pdateCommand.Co nnection =
    this.SqlConn1.C onn;
    this.oAdapter.U pdatecommand.Pa rameters.Add(@u serid,SqlDbType .Int);
    this.oAdapter.U pdateCommand.Pa rameters["@UserId"].Value
    = Convert.ToInt32 (this.fldUserId .Text); // dtTmp.Rows[0]["UserId"]; //
    this.oRow["UserId"];
    this.oAdapter.I nsertCommand = oCmd.InsertComm and;
    this.oAdapter.I nsertCommand.Co nnection =
    this.SqlConn1.C onn;

    this.oAdapter.U pdate(this.dtTm p); //dtTmp is a
    table with 1 Row and the userid is part of the table





Working...