Click here to Skip to main content
15,608,652 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
please see the code:
SqlConnection con = Database.GetConnection();

SqlCommand cmd = new SqlCommand("spArticleCategoryWise", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@cat_id", cat_ID);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
DataTable dt = (DataTable)ds.Tables["spArticleCategoryWise"];
int totalrows = dt.Rows.Count;
Label1.Text = totalrows.ToString();

Error:Object reference not set to an instance of an object.

please help me

Thanks in advance
Updated 24-Jun-11 20:16pm

1 solution

In which the error occurs?

It simply means that you are trying to use a property of an null object(the object is null).

So, put breakpoints in your code, debug & fix yourself. Check data in those objects.
Share this answer
Espen Harlinn 25-Jun-11 13:13pm    
Nice and simple, my 5

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