ds.Tables[0].Rows.Count > 1

问题描述:

ds.Tables[0].Rows.Count > 1
private void button2_Click_1(object sender,EventArgs e)
{
DataSet ds = new DataSet();
string consqlserver = "Data Source=.;Initial Catalog=留言板;Integrated Security=SSPI";
string sql = "SELECT * FROM liuyan";
SqlConnection con = new SqlConnection(consqlserver);
SqlDataAdapter da = new SqlDataAdapter(sql,con);
try
{
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 1)
{
dataGridView1.DataSource = ds.Tables[0];
}
}
catch
{
}
finally
{
con.Close();
con.Dispose();
da.Dispose();
}
}

DataSet ds = new DataSet();// 创建一个内存集合,就像一个大大框一样,里面可以放很多很多的tablestring consqlserver = "Data Source=.;Initial Catalog=留言板;Integrated Security=SSPI";//字符串连接string sql ...