使用c#怎么得到name列下的记录数,我只会到这里string strsqlname="select Name from " + tablename + "";

来源:百度知道 编辑:UC知道 时间:2024/06/29 01:07:26
string strsqlname="select Name from " + tablename + "";
SqlConnection connsql = new SqlConnection();
connsql.ConnectionString = PublicVariet.ConnectionString;
SqlCommand mycommandsql = new SqlCommand(strsqlname, connsql);
connsql.Open();
我只能写这么多啦,谢谢

SqlDataAdapter da = new SqlDataAdapter(strsqlname, connsql);
DataSet ds = new DataSet();
da.Fill(ds, "INFO");
con.Close();
foreach (DataRow row in ds.Tables["INFO"].Rows)
{
string nameinfo= row["name"].ToString().Trim();
Response.Write(nameinfo);
}