SQL在ASP.Net中选择查询 [英] SQL Select Query in ASP.Net

查看:54
本文介绍了SQL在ASP.Net中选择查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表中有一列包含(电话号码,电子邮件)等信息,我希望这个电话号码显示在标签中。我是ASP.Net和SQL的新手。请帮我。这是我的连接字符串,我还需要做什么。





I have a column in a table that contains information like(phone number, Email)and I want this phone number to be displayed in a label.I am new in ASP.Net and SQL. Please Help me. Here is my connection string, what else I have to do.


SqlConnection vcon = new SqlConnection(ConfigurationManager.ConnectionStrings["BBAConnectionString1"].ToString());

推荐答案

试试这段代码:

Try this code:
vcon.Open();
SqlCommand cmd = new SqlCommand(your Query, vcon);//Advised to use parameterized query
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
    txtExamId.Text = dr.GetValue(0).ToString();
    dr.close();
}
 vcon.Close();



问候..:)


Regards..:)


 SqlConnection vcon = new SqlConnection(ConfigurationManager.ConnectionStrings["BBAConnectionString1"].ToString());
Vcon.Open();
SqlCommand cmd = new Sqlcommand (select phonenumber from Tablename,Vcon);
label1.Text = Convert.ToString(cmd.ExcuteScalar());
Vcon.Close();


嗨请看这个链接:



http://support.microsoft.com/kb/320714 [ ^ ]





试试按照给出的例子。 :)

希望它会对你有帮助。
Hi Please see this Link:

http://support.microsoft.com/kb/320714[^]


Try to follow the example given. :)
Hope it will help you.


这篇关于SQL在ASP.Net中选择查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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