Click here to Skip to main content
15,886,700 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
SqlDataAdapter da = new SqlDataAdapter("select * from Apprs_Mast WHERE Facility_Status NOT IN ('DISBURSED','DENIED') order by Appraisal_No", sqlCon);

DataSet ds = new DataSet();
da.Fill(ds, "Apprs_Mast");









GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
Posted

In your code fragment, a data set is always empty. No need to check it up.

—SA
 
Share this answer
 
Comments
Member 10744248 28-Sep-14 17:58pm    
I'm having an error each time the table is empty
Sergey Alexandrovich Kryukov 28-Sep-14 20:53pm    
Most likely, you are talking about exceptions, not error.
You do some mistake assuming the data set is not empty. If you show me the line where the exception is thrown, I'll tell you what is your mistake.

Like in your SqlDataAdapter.Fill. Look at this sample from http://msdn.microsoft.com/en-us/library/y4b211hz%28v=vs.110%29.aspx:

DataSet dataset = new DataSet();
dataset.Tables.Add("aaa");
dataset.Tables.Add("AAA");
adapter.Fill(dataset, "aaa"); // Fills "aaa", which already exists in the DataSet.
adapter.Fill(dataset, "Aaa"); // Adds a new table called "Aaa"

Compare with your code. What's do you think is its meaning?

—SA
ASM
DataSet ds = new DataSet();
da.Fill(ds, "Apprs_Mast");

Check the dataset default table rows count

if(ds.tables[0].rows.count>0)
{
//Implement your logic if rows are present
}
else
{
//exit if there is no rows
return;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900