Object reference not set to an instance of an object

  • Thread starter Andy Sutorius via DotNetMonster.com
  • Start date
A

Andy Sutorius via DotNetMonster.com

Hi,

I am pulling my hair out! I don't see why I am getting the error message.
There is data in the data reader. Notice that I have actually performed a
while/read on the data reader. Does anyone see why I am getting this error?

Thanks,

Andy

private void BindTypeDropDown()
{
SqlConnection oConn = new SqlConnection(DBConnectionString);
SqlCommand lCommand = new SqlCommand("sp_web_835_ddl_type",oConn);
lCommand.CommandType=CommandType.StoredProcedure;

oConn.Open();
SqlDataReader dtrTypeDDL = lCommand.ExecuteReader();

// while (dtrTypeDDL.Read())
// {
// Response.Write(dtrTypeDDL["code_value"] + " " + dtrTypeDDL
["short_description"] + "<br>");
// }

// Response.End();

ddlType.DataSource = dtrTypeDDL;
ddlType.DataValueField = "code_value";
ddlType.DataTextField = "short_description";
ddlType.DataBind();

dtrTypeDDL.Close();
oConn.Close();
}


Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:


Line 87: // Response.End();
Line 88:
Line 89: ddlType.DataSource = dtrTypeDDL;
Line 90: ddlType.DataValueField = "code_value";
Line 91: ddlType.DataTextField = "short_description";


Source File: c:\inetpub\wwwroot\ecui_1\wpclaimansi835data.aspx.cs Line:
89
 
A

Alvin Bruney [MVP - ASP.NET]

what is at line 89?

--
Regards,
Alvin Bruney - ASP.NET MVP

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
Now available @ www.lulu.com/owc, Amazon.com etc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top