Object reference not set to an instance of an object.

D

David

Using a COM object to retrieve data from a SQL Server (middle tier).
The COM object returns the data in XML format.
In VB.NET, run the following Page Load code to obtain the XML string
and to transform it so that a <SELECT> drop-down appears on the
screen:

....
Dim XMLString As String
Dim myUser As System.Security.Principal.WindowsIdentity
Dim myClient As dClient.ITClient
Dim myXMLDoc As System.Xml.XmlDocument = New
System.Xml.XmlDocument
Dim myXMLTrans As System.Xml.Xsl.XslTransform = New
System.Xml.Xsl.XslTransform

'Show the current User
myUser = System.Security.Principal.WindowsIdentity.GetCurrent()
ResultName.InnerHtml() = "<BR>Welcome, " +
myUser.Name.Substring(CInt(myUser.Name.IndexOf("\") + 1),
CInt(CInt(myUser.Name.Length) - myUser.Name.IndexOf("\") - 1)) +
"&nbsp;&nbsp;"

'Fill the first drop down list with list of Clients
myClient = CreateObject("dClient.TClient")
XMLString = myClient.Select("select ridClient, valName from
tblClient").ToString
myXMLDoc.LoadXml(XMLString.ToString)
myXMLTrans.Load(Server.MapPath("styles1.xsl"))
Xml2.Document = myXMLDoc
Xml2.Transform = myXMLTrans

....

This results in a <SELECT id> box (with values) appearing in place of
the XML (System.Web.UI.WebControls.Xml) control on the HTML page.
i.e.:
....
Client:
<?xml version="1.0" encoding="utf-8"?>
<SELECT id="dropDownClient" name="dropDownClient"
runat="server"><OPTION></OPTION><OPTION>Max.
I.T.</OPTION><OPTION>APCS</OPTION><OPTION>The Age</OPTION></SELECT>
<input type="submit" name="cmdSelect" value="Select" id="cmdSelect" />
....

However, when I try, in the cmdSelect.Click event of the button to
access the value of the dropDownClient using dropDownClient.Value, I
get the Object reference not set to an instance of an object error.
So, the question is, what am I missing? I also do have the line:

Protected WithEvents dropDownClient As
System.Web.UI.HtmlControls.HtmlSelect

at the top of the code page, but makes no difference.
 
S

Sohail

-----Original Message-----
However, when I try, in the cmdSelect.Click event of the button to
access the value of the dropDownClient using dropDownClient.Value, I
get the Object reference not set to an instance of an object error.
So, the question is, what am I missing? I also do have the line:

Protected WithEvents dropDownClient As
System.Web.UI.HtmlControls.HtmlSelect

at the top of the code page, but makes no difference.
.

The problem is likely that you are running an antivirus
software. Disable this. I had this problem and it was a
bitch to solve. What happens is that your antivirus (or
some similar prog) scans your global.*x file and aspnet
thinks that its been changed so it recompiles and you lose
all your variables.

Good luck
 

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

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top