如何使用c#生成Sql数据库脚本,net用于插入和更新? [英] How to generate Sql Database Script using c# ,net for insert and update?

查看:215
本文介绍了如何使用c#生成Sql数据库脚本,net用于插入和更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



如何使用c#.net生成Sql Database Script,一次插入和更新?



先谢谢。



Ankit Agarwal

软件工程师

Hello,

How to generate Sql Database Script using c# .net for insert and update at a time?

Thanks in Advance.

Ankit Agarwal
Software Engineer

推荐答案

您需要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


这篇关于如何使用c#生成Sql数据库脚本,net用于插入和更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆