D
daveL
hello below is my sqldatadapter setup
it is inserting a row when it should be updating a row
can you tell me what the problem is
SqlDataAdapter ad = new SqlDataAdapter();
ad.SelectCommand = new SqlCommand("select * from users order
by userid");
ad.SelectCommand.Connection = this.SqlConn1.Conn;
SqlCommandBuilder cmd = new SqlCommandBuilder(ad);
ad.InsertCommand = cmd.GetInsertCommand();
ad.UpdateCommand = cmd.GetUpdateCommand();
ad.UpdateCommand.Connection = this.SqlConn1.Conn;
ad.InsertCommand.Connection = this.SqlConn1.Conn;
ad.UpdateCommand.Parameters.Add("@Userid", SqlDbType.Int);
ad.UpdateCommand.Parameters["@UserId"].SourceColumn =
"UserId";
ad.Update(dtTmp) // dtTmp has 1 row (datatable)
it is inserting a row when it should be updating a row
can you tell me what the problem is
SqlDataAdapter ad = new SqlDataAdapter();
ad.SelectCommand = new SqlCommand("select * from users order
by userid");
ad.SelectCommand.Connection = this.SqlConn1.Conn;
SqlCommandBuilder cmd = new SqlCommandBuilder(ad);
ad.InsertCommand = cmd.GetInsertCommand();
ad.UpdateCommand = cmd.GetUpdateCommand();
ad.UpdateCommand.Connection = this.SqlConn1.Conn;
ad.InsertCommand.Connection = this.SqlConn1.Conn;
ad.UpdateCommand.Parameters.Add("@Userid", SqlDbType.Int);
ad.UpdateCommand.Parameters["@UserId"].SourceColumn =
"UserId";
ad.Update(dtTmp) // dtTmp has 1 row (datatable)