Click here to Skip to main content
15,900,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
dt2 = cmod.bind_grdview_city();
if(dt2.Rows.Count>0)

{
grdview_city.DataSource = dt2;
grdview_city.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}





i am using 3 tier archetecture----------------------below is my function that is calling...




public DataTable bind_grdview_city()
{
try
{
cmd.Parameters.Add("@opt", SqlDbType.Int).Value = 3;
dt = cn.getDBDatatable("proc_city", cmd);
return dt;
}
catch (Exception ex)
{
throw ex;
}
finally
{
cn.closeConnection();
}


}
Posted
Comments
[no name] 25-Mar-14 7:46am    
You are trying to access the method or properties of an object that has not been instantiated. Debug your code to find out what it is.
BillWoodruff 25-Mar-14 9:02am    
Put a break-point on the first line of the method, and then single-step through it with F11, until you encounter an error: post where the error occurred here.

1 solution

Possible candidates to throw this error are dt due to no matching record found. other possibility is cmd if it is not initialized.
 
Share this answer
 
v2

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