且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用c#生成Sql数据库脚本,net用于插入和更新?

更新时间:2023-02-07 14:49:44

您需要Google并阅读使用DataAdapter的信息。



基本上,该过程是在特定的SQL select语句上创建DataAdapter。

然后你可以使用CommandBuilder从你的SQL select语句派生一个insert,update和delete sql命令 - 或者(***)你可以传入你自己的IUD SQL语句。

然后使用DataAdapter的Fill函数填充数据表以读取数据库中的行。

如果数据表中有0行,则需要添加新行。 (这将是一个插入)。

更新你喜欢的数据表中的行。



然后运行DataAdapter的更新功能更新数据库。



祝你好运
You will want to Google and read up on using a DataAdapter.

Basically the process is to create a DataAdapter on a specific SQL select statement.
Then you can use a CommandBuilder to derive an insert, update, and delete sql command from your SQL select statement - or (preferably) you can pass in your own IUD SQL statements.
Then fill a data table using the DataAdapter's Fill function to read the row out of the database.
If the data table has 0 rows in it, you will need to add a new row. (This will be an insert).
Update the row in the data table however you like.

Then run the DataAdapter's Update function to update the database.

Good Luck