如何将CommandObject存储在字符串中 [英] how to store commandobject in a string

查看:60
本文介绍了如何将CommandObject存储在字符串中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MySqlCommand  com = new MySqlCommand(" Select P.productname from productmast P join userpermission U on P.pid=U.uid innerjoin adminusermast A on U.adminuserid = A.adminuserid where ((A.adminuserid = 2) OR (A.adminuserid <> 2)) AND (U.permissionstatus = true))" , myPConn);




我现在写此查询,我想将其存储在字符串SQeury = com;中,但是它不起作用,所以我如何存储它.




I write this query now i want to store it in a string SQeury = com; but its not working So how i store it .

推荐答案

您要存储在字符串中的内容字符串?
您要存储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


这篇关于如何将CommandObject存储在字符串中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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