|
Find eligible records from the database and update!
Why does the old error "Dynamic SQL generation of UpdateCommand not supported for SelectCommand that does not return any key column information."?
How to modify it, I just learned ASP.net, please take care
string m_sql = "select * from item where id = 2277";
Ranch
SqlConnection sqlConnection1 = new SqlConnection (strConn);
SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter (m_sql, sqlConnection1) ;;
DataSet dataset = new DataSet ();
SqlCommandBuilder sqlcommandbuilder = new SqlCommandBuilder (sqlDataAdapter1);
Ranch
sqlConnection1.Open ();
sqlDataAdapter1.Fill (dataset, "ly");
sqlConnection1.Close ();
if (dataset.Tables [0] .Rows [0] ["item_serial"]. ToString () == "048")
{
Label1.Text = "Yes";
dataset.Tables [0] .Rows [0] ["item_serial"] = "hello"
sqlDataAdapter1.Update (dataset, "ly");
}
else
{
Label1.Text = "NO";
} |
|