日期:2014-05-18  浏览次数:20491 次

输出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();