简体   繁体   English

C#CommandBuilder的替代方法或使用CommandBuilder的方式没有连接?

[英]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设计有工作SqlDataAdapterSqlCommand对象,或者只是一个SqlCommand ,并从documenttation需要连接到数据库检索信息玛

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法使用SQL和CommandBuilder C#添加行 - Cannot Add a Row Using SQL and CommandBuilder C# 无法通过ODBCDataAdapter / CommandBuilder更新进度表 - Cannot update Progress table through ODBCDataAdapter/CommandBuilder C#.NET sqlDatabase CommandBuilder 和 DataAdapter:名称“适配器”在当前上下文中不存在 - C#.NET sqlDatabase CommandBuilder and DataAdapter: The name 'Adapter' does not exit in the current context ADO.NET CommandBuilder、InsertCommand 和默认约束 - ADO.NET CommandBuilder, InsertCommand and Default Constraints C#-使用属性的替代方法 - C# - Alternative way to use attribute C# 在异步任务中使用 sql 连接的最佳方式 - C# best way to use sql connection in async task 在C#中合并Excel工作表的替代方法 - Alternative way of merging excel worksheets in c# 在不使用odbc的情况下将c#与mysql一起使用的最佳方法是什么 - what is the best way to use c# with mysql without using odbc 有没有办法在没有Internet连接的情况下从独立的C#应用​​程序验证YubiKey? - Is there a way to authenticate YubiKey from stand-alone C# application without internet connection? 使用c#Mutex类的这种替代方式是否有任何损失? - Are there any loss in this alternative way of using c# Mutex class?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM