C#读取sql2000的一个数值的问题 请问怎样写C#读取sql2000的一个数值,如在TextBox1中显示sql2000数据库中的一个数值,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 SqlConnection conn = new SqlConnection("连接字串");SqlCommand cmd = new SqlCommand("你的SQL语句",conn);try{ int total = (int)cmd.ExecuteScalar(); conn.Close();}catch{ HttpContext.Current.Response.Redirect("error.aspx?type=other");}finally{} SqlConnection conn = new SqlConnection("连接字串");SqlCommand cmd = new SqlCommand("你的SQL语句",conn);try{ int total = (int)cmd.ExecuteScalar(); conn.Close();}catch{ HttpContext.Current.Response.Redirect("error.aspx?type=other");}finally{} SQL ="select * from table where name='test'";SqlConnection myConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectString"]);myConnection.Open();SqlCommand myCommand = new SqlCommand(SQL,myConnection);SqlDataReader myReader= myCommand.ExecuteReader();while(myReader.Read()){ TextBox1.Text=myReader["name"].ToString(); .....}myReader.Close(); sql = "select mycol from mytable where 1=1";在写一个sqlcommand,执行sql语句,可以返回dataset或者datareader或者直接excutescalar具体代码自己找找,这个上面或者msdn上多多的 回复人: baobei7758(陵少) ( ) 信誉:100 类似团购网上 怎样用拼音开头字母选择城市 跪求dropdownlist和gridview的组合数据库查询 关于版本的问题 【高手快来救命啊]】 我想做一个类似于http://www.yanmingxuan.com.cn的购物网站 请教高手关于文本框与日期控件的问题: 请问Forms身份验证和角色的问题 如何将首页生成静态页面?? 各位大哥大姐我想给GridView添加颜色,有没有好的例子或建议,请指点!多谢多谢! 这是什么情况,在线等,用vs编译一个管理系统,出现的情况 ASP中关于日期格式转换的问题 为什么.net里的md5加密和asp里的md5加密得到结果不一样?
SqlCommand cmd = new SqlCommand("你的SQL语句",conn);
try
{
int total = (int)cmd.ExecuteScalar();
conn.Close();
}
catch
{
HttpContext.Current.Response.Redirect("error.aspx?type=other");
}
finally
{}
SqlCommand cmd = new SqlCommand("你的SQL语句",conn);
try
{
int total = (int)cmd.ExecuteScalar();
conn.Close();
}
catch
{
HttpContext.Current.Response.Redirect("error.aspx?type=other");
}
finally
{}
SqlConnection myConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectString"]);
myConnection.Open();SqlCommand myCommand = new SqlCommand(SQL,myConnection);
SqlDataReader myReader= myCommand.ExecuteReader();
while(myReader.Read())
{
TextBox1.Text=myReader["name"].ToString();
.....}
myReader.Close();
在写一个sqlcommand,执行sql语句,可以返回dataset或者datareader或者直接excutescalar
具体代码自己找找,这个上面或者msdn上多多的