The insert, update, and delete statements generated by commandbuilder can only be used for one table. If the current dataset able contains multiple tables or computing columns, you cannot use comandbuilder.
To
I have been confused about how to update batch data in. net. I made a lowest-level error and can write insert, update, and delete statements by myself.
Of course, there will be only one table operation in the statement. The value part is parameterized with "@ parameter", and then parameterization is added to the parameters of each command
I always thought that only one specific value parameter could be added in ADO. The original ADO. Net method can be specified" Source Column ", In this way, the specific parameterization method called is ADO. net, and the corresponding column value of the datarow to be processed will be automatically retrieved from the current dataset.
The same method is used to call stored procedures.
Use the parameter name, sqldbtype, size, and source column name to initialize a new instance of the sqlparameter class.
[Visual Basic]Public sub new (_ byvalParameternameAsString,_ ByvalDbtypeAsSqldbtype,_ ByvalSizeAsInteger,_ ByvalSourcecolumnAsString_ )
[C #]Public sqlparameter (
String Parametername,
Sqldbtype Dbtype,
Int Size,
String Sourcecolumn
);
[C ++]Public: sqlparameter (String*Parametername, Sqldbtype Dbtype, Int Size, String*Sourcecolumn );
[JScript]Public Function sqlparameter (Parametername:String, Dbtype:Sqldbtype, Size:Int, Sourcecolumn:String);
Parameters
-
Parametername
-
The name of the parameter to be mapped.
-
Dbtype
-
One of the sqldbtype values.
-
Size
-
The length of the parameter.
-
Sourcecolumn
-
The name of the source column.
For example:
Da. selectcommand: Select table1.id, table1.name, table2.address from Table1, Table2 where table1.id = table2.id
Da. insertcommand = new sqlcommand ("insert into test (ID, name) values (@ ID, @ name )");
Da. insertcommand. Parameters. Add ("@ ID", sqldbtype. nvarchar, 4, "ID ");
Da. insertcommand. Parameters. Add ("@ ID", sqldbtype. nvarchar, 10, "name ");
Da. Update (DS );