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)) +
" "
'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.
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)) +
" "
'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.