获取查出来的值
我的语句是这样的
string str1 = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString.ToString();
SqlConnection con = new SqlConnection(str1);
con.Open();
string stri1 = "select count(*) from syscolumns where=id=object_id('" + Session["table"] + "')";
SqlCommand com = new SqlCommand(stri1, con);
com.ExecuteNonQuery();
我要把查询出来的数据表列数赋值给一个int型的变量,怎么做?
------解决方案--------------------
com.ExecuteNonQuery();--这个是影响行数
int count=Convert.ToInt32(Com.ExecuteScalar());
------解决方案--------------------int countResult = (int)com.ExecuteScalar();
------解决方案--------------------