|
Write the corresponding SQL statement yourself:
Probably as follows:
In fact, you still write sentences yourself, because there are a lot of garbage generated automatically, for example,
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT INTO student (stuno, name) VALUES (@stuno, @name)";
this.sqlInsertCommand1.Connection = this.conn;
this.sqlInsertCommand1.Parameters.Add (new System.Data.SqlClient.SqlParameter ("@ stuno", System.Data.SqlDbType.VarChar, 4, "stuno"));
this.sqlInsertCommand1.Parameters.Add (new System.Data.SqlClient.SqlParameter ("@ name", System.Data.SqlDbType.VarChar, 50, "name"));
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = "UPDATE student SET stuno = @stuno, name = @name WHERE (stuno = @Original_stuno)";
this.sqlUpdateCommand1.Connection = this.conn;
this.sqlUpdateCommand1.Parameters.Add (new System.Data.SqlClient.SqlParameter ("@ stuno", System.Data.SqlDbType.VarChar, 4, "stuno"));
this.sqlUpdateCommand1.Parameters.Add (new System.Data.SqlClient.SqlParameter ("@ name", System.Data.SqlDbType.VarChar, 50, "name"));
this.sqlUpdateCommand1.Parameters.Add (new System.Data.SqlClient.SqlParameter ("@ Original_stuno", System.Data.SqlDbType.VarChar, 4, System.Data.ParameterDirection.Input, false, ((System.Byte) (0 )), ((System.Byte) (0)), "stuno", System.Data.DataRowVersion.Original, null));
// sqlDeleteCommand1
//
this.sqlDeleteCommand1.CommandText = "DELETE FROM student WHERE (stuno = @Original_stuno)";
this.sqlDeleteCommand1.Connection = this.conn;
this.sqlDeleteCommand1.Parameters.Add (new System.Data.SqlClient.SqlParameter ("@ Original_stuno", System.Data.SqlDbType.VarChar, 4, System.Data.ParameterDirection.Input, false, ((System.Byte) (0 )), ((System.Byte) (0)), "stuno", System.Data.DataRowVersion.Original, null));
this.sqlDa.DeleteCommand = this.sqlDeleteCommand1;
this.sqlDa.InsertCommand = this.sqlInsertCommand1;
this.sqlDa.UpdateCommand = this.sqlUpdateCommand1;
try
{
sqlDa.Update (dt.GetChanges, "student");
return true;
}
catch (System.Data.SqlClient.SqlException ex)
{
return false;
}
finally
{
conn.Close ();
} |
|