当前位置: 代码迷 >> ASP.NET >> 输出select语句的值到textbox解决思路
  详细解决方案

输出select语句的值到textbox解决思路

热度:4185   发布时间:2013-02-25 00:00:00.0
输出select语句的值到textbox
textbox1.text= "select语句 ".ToString();
我这样写不行,该怎么写呢

------解决方案--------------------------------------------------------
textbox1.text=cmd.ExecuteScalar( "select 第一行第1列的语句 ");
------解决方案--------------------------------------------------------
textbox1.text=command.ExecuteScalar().tostring() 试试
ExecuteScalar是返回第一行的一列
------解决方案--------------------------------------------------------
SqlConnection con = new SqlConnection( "connectionString ");
SqlCommand commd = new SqlCommand( "select语句 ", con);
con.Open();
textbox1.text=commd.ExecuteScalar().ToString();
commd.Dispose();
con.Close();
  相关解决方案