ds.Tables[0].Rows.Count>1
privatevoidbutton2_Click_1(objectsender,EventArgse)
{
DataSetds=newDataSet();
stringconsqlserver="DataSource=.;InitialCatalog=留言板;IntegratedSecurity=SSPI";
stringsql="SELECT*FROMliuyan";
SqlConnectioncon=newSqlConnection(consqlserver);
SqlDataAdapterda=newSqlDataAdapter(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();
}
}