且构网

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

如何将CommandObject存储在字符串中

更新时间:2022-06-17 04:50:28

您要存储在字符串中的内容字符串?
您要存储sql查询或整个com对象...
如果您要存储整个com对象,那么
我认为这不可能
what u want to store in a string?
You want to store the sql query or entire com object...
If u r trying to store entire com object then
I think It is not possible


是的,不可能将cmd对象存储在字符串中.
如果您想查询,请使用它.

Yes it is not possible to store cmd object in string.
if you want to get query then use this.

string query=cmd.CommandText;




试试这个

Hi,

try this

string val=com.ExecuteScalar ().tostring();



在sql中执行后返回查询结果
***的



It returns the result of your query after executing in sql

All the Best