如何从查询中获取值并将这些值存储到字符串变量中。 [英] how to get value from query and store these value into the string variable.
本文介绍了如何从查询中获取值并将这些值存储到字符串变量中。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
cn.Open();
string name;
string pass;
string query = "select user_name,password from login_detail where user_name='" + text_user_name + "' & password='" + text_password + "'";
cmd = new OleDbCommand(query, cn);
我想将user_name存储到名称
&密码进入传递
。帮助我...
I want to store user_name into name
& password into pass
. help me...
推荐答案
试试这个
Try this
cmd = new OleDbCommand(query, cn);
cn.Open();
OleDbDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
name = reader.GetString(0);
pass = reader.GetString(1);
}
看看:
OleDbCommand Class [ ^ ]
那里你会找到关于你正在使用的课程的完整文档,以及一些如何实际使用它的例子。
祝你好运。
Have a look at that:
OleDbCommand Class[^]
There you will find a complete documentation on the class you are using, as well as some examples on how to actually use it.
Good luck.
参考并尝试:
http://www.aspsnippets.com/Articles/Simple-User-Registration-Form-Example-in-ASPNet.aspx [ ^ ]
htt p://www.aspdotnet-suresh.com/2010/10/how-to-get-output-parameters-return-by.html [ ^ ]
Refer and try :
http://www.aspsnippets.com/Articles/Simple-User-Registration-Form-Example-in-ASPNet.aspx[^]
http://www.aspdotnet-suresh.com/2010/10/how-to-get-output-parameters-return-by.html[^]
这篇关于如何从查询中获取值并将这些值存储到字符串变量中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文