[英]C# CommandBuilder alternative or way to use CommandBuilder without a connection?
I need to (at runtime) build some SQL statements to update a database that I am NOT connected to. 我需要(在运行时)构建一些SQL语句来更新我没有连接到的数据库。 Right now I am using a String.Format to build the query, but it's difficult to deal with all the different parameter cases (different datatypes, null, values, escaping, etc..).
现在我使用String.Format来构建查询,但是很难处理所有不同的参数情况(不同的数据类型,null,值,转义等等)。
What I'd like is to use CommandBuilder--but CommandBuilder requires a DataAdapter which requires a connection and I'm not connected to my database (this is a stand alone utility). 我想要的是使用CommandBuilder - 但CommandBuilder需要一个DataAdapter,它需要一个连接而我没有连接到我的数据库(这是一个独立的实用程序)。
Is there a way to use CommandBuilder in a disconnected state or how can I build this well formatted SQL query in a way that will require me to write a minimal amount of code? 有没有办法在断开状态下使用CommandBuilder,或者如何以一种需要我编写最少量代码的方式构建这个格式良好的SQL查询?
(Target DB is SQL Server) (目标数据库是SQL Server)
Is there a way to use CommandBuilder in a disconnected state?
有没有办法在断开状态下使用CommandBuilder?
Unfortunately NO . 不幸的是NO 。
SqlCommandBuilder
is designed to work with a SqlDataAdapter
and a SqlCommand
object, or just a SqlCommand
, and from the documenttation it needs to connect to the database to retrieve information shema . SqlCommandBuilder
设计有工作SqlDataAdapter
和SqlCommand
对象,或者只是一个SqlCommand
,并从documenttation它需要连接到数据库检索信息玛 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.