The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Ebaad (3) [Avatar] Offline
#1
Hello,

This the first time I am trying to use the AJAX, I have a db in access that I'm trying to make a frontend for, this ia an application for tracking patient exams. I have debugged my code and have been hassling to get it to work for about three days, this is the farthest I have got so far and now I am getting the following error while connecting and fetching the data from db, may be I'm not using the correct query/connection string, I also have established a DSN ODBC connection for the db. At this point I'm really tired and need some help desperately.

error fetching data!

ready state:4
status:500

My DoubleComboXML.aspx is as follows,

Private Sub Page_Load( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load

Response.ContentType = "text/xml"

Dim strQuery As String
strQuery = Request.Form("q")
Dim strForm As String
strForm = Request.Form("f")
Dim strElem As String
strElem = Request.Form("e")

Dim strSql As String = "SELECT " &_
"PHYID, " &_
"PHYSICIAN " &_
"FROM tblPHYSICIAN " &_
"WHERE DEPARTMENT = " &_
strQuery & " ORDER BY " &_
"PHYSICIAN"

Dim dtOptions As DataTable
dtOptions = FillDataTable(strSql)

Dim strXML As StringBuilder
strXML = New StringBuilder("<?xml " &_ <br /> "version=""1.0"" ?>")
strXML.Append("<selectChoice>")
strXML.Append("<selectElement>")
strXML.Append("<formName>" &_
strForm &_
"</formName>")
strXML.Append("<fromElem>" &_
strElem &_
"</fromElem>")
strXML.Append("</selectElement>")

If dtOptions.Rows.Count > 0 Then

strXML.Append("<entry>")
strXML.Append("<optionText>" &_
"Select a Physician" &_
"</optionText>")
strXML.Append("<optionValue> -1" &_
"</optionValue>")
strXML.Append("</entry>")

Dim row As DataRow
For Each row In dtOptions.Rows
strXML.Append("<entry>")
strXML.Append"<optionText>" &_
row("PHYSICIAN") &_
"</optionText>")
strXML.Append("<optionValue>" &_
row("PHID") &_
"</optionValue>")
strXML.Append("</entry>")
Next
EndIf

strXML.Append("</selectChoice>")
Response.Write(strXML.ToString)

EndSub

Public Function FillDataTable( _
ByVal sqlQuery As String) _
As DataTable

Dim strConn As String = _
"Initial Catalog = oelog; " &_
"Data Source=127.0.0.1; " &_
"Integradted Security=true;"
Dim cmd1 As _
New SqlClient.SqlDataAdapter(sqlQuery, strConn)

Dim dataSet1 As New DataSet
cmd1.Fill(dataSet1)
cmd1.Dispose()
Return dataSet1.Tables(0)
End Function


I would really appreciate if somebody can help me with this as I need this front end for tracking patient data. I can post the code if that helps for resolving the issue.

Thanks,
Ebaad.
Pascarello (208) [Avatar] Offline
#2
Re: DoubleCombo Dropdown List
If you access the URL directly in the browser what happens? (You would have to hardcode the Request.Form or change it to Request.Params and use querystring values)

If you add break points on the server does it get there?

Eric
Ebaad (3) [Avatar] Offline
#3
Re: DoubleCombo Dropdown List
Hi Eric,

Thanks for the response, I'm sorry that I could not check the email earlier as I had to go away from my home. Now I'm back and saw your message, I have again two questions that where specifically you want me to change the request.params and I do have the breakpoints and alert messages set in the main asp file but how can I set them in an .aspx file. I can access the server side since.........oh may be I can setup some alerts in net.js and see if it is getting any values to setup the correct query. I checked the values before sending to the net.js but not after it gets received by net.js and I still need to learn that how can I setup some kind of checks in .aspx file or save the xml out put to see if it is in the correct format.

Again I really appreciate every help that I can get, I have not asked for it until I was really sure that I cannot move any forward without asking somebody.

Thanks,
Ebaad.
Ebaad (3) [Avatar] Offline
#4
Re: DoubleCombo Dropdown List
Hi Eric,

I placed the following alert with in the net.contenetloader()
net.ContentLoader=function(url,onload,onerror,method,params,contentType){
alert("URL: "+url
+"
Params: "+params
+"
Content Type: "+contentType
+"
METHOD: "+method
+"
ONLOAD: "+onload);
this.req=null;
this.onload=onload;
this.onerror=(onerror) ? onerror : this.defaultError;
this.loadXMLDoc(url,method,params,contentType);
}

And the only thing that resulted undefined was "contentType". Other wise I get the following output from the alert message,
URL: DoubleComboXML.aspx
Params: f=form1&e=PHYSICIAN&q=PEDE SURG>
Content Type: undefined
METHOD: POST
ONLOAD: function FillDropDown(){
......
.....
....
...
..
.

I would really appreciate any help, as I'm still getting the same error.
Thanks,
Ebaad

Message was edited by:
Ebaad