T
trialproduct2004
Hi all,
i am having code as following:-
SqlCommandBuilder cmd;
da = new SqlDataAdapter("select status,id,mode from test1,test2 where
test1.id = test2.id;", mConn);
cmd = new SqlCommandBuilder(da);
DataSet ds;
ds=new DataSet();
da.Fill(ds);
da.UpdateCommand = new SqlCommand("update test1 set status = @status
where id = @id;update test2 set mode = 'p' where id = @id ",mConn );
da.UpdateCommand.Parameters.Add("@status",SqlDbType.Int,0,"status");
da.UpdateCommand.Parameters.Add("@id",SqlDbType.VarChar ,50,"id");
DataRow [] drc = ds.Tables[0].Select("id = 'O9485330060927155857741 '
");
foreach(DataRow dr in drc)
{
dr["status"] = 333;
}
da.Update(ds.Tables[0]);
Can anyone tell me whether above code is correct or not.
This code is updating 2 tables test1 and test2 using one adapter. it is
setting status in table 1 to '333' and mode in test2 to 'p'. I heard
somewhere that u can't update 2 tables with one adatper. But above
mention code is working properly in my case.
So i am not sure whetehr there is any error in my code or not. Or will
it create any error in future because i want to run this code on
database that has large amount of data.
If i am wrong please correct me.
thanks in advance.
i am having code as following:-
SqlCommandBuilder cmd;
da = new SqlDataAdapter("select status,id,mode from test1,test2 where
test1.id = test2.id;", mConn);
cmd = new SqlCommandBuilder(da);
DataSet ds;
ds=new DataSet();
da.Fill(ds);
da.UpdateCommand = new SqlCommand("update test1 set status = @status
where id = @id;update test2 set mode = 'p' where id = @id ",mConn );
da.UpdateCommand.Parameters.Add("@status",SqlDbType.Int,0,"status");
da.UpdateCommand.Parameters.Add("@id",SqlDbType.VarChar ,50,"id");
DataRow [] drc = ds.Tables[0].Select("id = 'O9485330060927155857741 '
");
foreach(DataRow dr in drc)
{
dr["status"] = 333;
}
da.Update(ds.Tables[0]);
Can anyone tell me whether above code is correct or not.
This code is updating 2 tables test1 and test2 using one adapter. it is
setting status in table 1 to '333' and mode in test2 to 'p'. I heard
somewhere that u can't update 2 tables with one adatper. But above
mention code is working properly in my case.
So i am not sure whetehr there is any error in my code or not. Or will
it create any error in future because i want to run this code on
database that has large amount of data.
If i am wrong please correct me.
thanks in advance.