Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Dale on Mar 11, 2009 11:30
open dhtmlx forum
Dynamic Grid using ASP and SQL server, problems loading more records

Hi guys,

I'm struggling again I think down to the lack of ASP documentation.  Be great if you could point me in the right direction.  I can get the initial rows to populate then when I scroll down I get an XML error.  No clue why so here's the code...

 

<script>
    var gridQString = "";//we'll save here the last url with query string we used for loading grid (see step 5 for details)
    //we'll use this script block for functions
</script>

<div id="products_grid" style="width:500px;height:200px;"></div>
<script>

    var mygrid = new dhtmlXGridObject('products_grid');

    mygrid.setImagePath("code/dhtmlxGrid/codebase/imgs/");

    mygrid.setHeader("Product Name,Internal Code,Price");

    mygrid.setInitWidths("*,150,150");

    mygrid.setColAlign("left,left,right");

    mygrid.setSkin("modern");

    mygrid.init();
 mygrid.enableSmartRendering(true,50);
 var gridQString = "";
 gridQString = "portal/substance_inventory/getGridRecords.asp";//save query string to global variable (see step 5 for details)
 mygrid.loadXML(gridQString);

</script>

 

- - - - - - - -

then this is my ASP page... (getGridRecords.asp)

 

<%@ LANGUAGE = VBScript %>
<% option explicit %>
<!--#include file="../../Connections/security_check.asp" -->
<!--#include file="../../Connections/connect.asp" -->
<% call open_conn() %>
<%
   
    ' set content type and xml tag
    Response.ContentType = "text/xml"
    Response.write("<?xml version=""1.0"" encoding=""UTF-8""?>")

    ' define variables from incoming values
    Dim posStart, count
    If not isEmpty(Request.QueryString("posStart")) Then
        posStart = Request.QueryString("posStart")
    Else
        posStart = 0
    End If   

    If not isEmpty(Request.QueryString("count")) Then
        count = Request.QueryString("count")
    Else
        count = 100
    End If   
   
    ' query to products table
    sql = "dbo.SP_my_msdss_all " & posStart & "," & count

    ' if this is the first query - get total number of records in the query result
    Dim sqlCount, totalCount
    If posStart = 0 Then
  Call open_read(sql,0)
        totalCount = rc("cnt")
    Else
        totalCount = ""   
    End If

    ' Next recordset
 set rc = rc.nextRecordSet()
 
 getResults = rc.getrows()
   
    ' output data in XML format  
    Response.write("<rows total_count='" & totalCount & "' pos='" & posStart & "'>")
    for counter=0 to ubound(getResults,2)
        Response.write("<row id='r" & eval(counter+posStart) & "'>")
            Response.write("<cell>")
                Response.write(getResults(1,counter))  ' value for product name
            Response.write("</cell>")
            Response.write("<cell>")
                Response.write(getResults(2,counter))  ' value for internal code
            Response.write("</cell>")
            Response.write("<cell>")
                Response.write(getResults(0,counter))    ' value for price
            Response.write("</cell>")
        Response.write("</row>")
    next
    Response.write("</rows>")
    rc.Close()

%>
<% call close_conn() %>

Thanks for the help!


Dale

Answer posted by Support on Mar 12, 2009 05:44
Incorrect XML error means that printed data has XML syntax errors, in case of dyn. generation of data, most possible reason

- some script error occurs during data generation and error info corrupt XML
- data was printed in different encoding than XML ( iso-8859-1 vs UTF ) which cause xml syntax error

To check exact reason, you can load the same url ( getGridRecords.asp with parameters ) in separate window or use debug version of dhtmlxcommon.js 

http://dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Common_Problems_in_Grid.html#grid_art_comprob
http://dhtmlx.com/docs/products/kb/index.shtml?cat=search&q=2545&ssr=yes&s=dhtmlxcommon
Answer posted by dhxSupport on Mar 12, 2009 06:45
Incorrect XML error means that printed data has XML syntax errors, in case of dyn. generation of data, most possible reason 

- some script error occurs during data generation and error info corrupt XML
- data was printed in different encoding than XML ( iso-8859-1 vs UTF ) which cause xml syntax error

To check exact reason, you can load the same url ( getGridRecords.asp with parameters ) in separate window or use debug version of dhtmlxcommon.js 

http://dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Common_Problems_in_Grid.html#grid_art_comprob
http://dhtmlx.com/docs/products/kb/index.shtml?cat=search&q=2545&ssr=yes&s=dhtmlxcommon
Answer posted by Dale on Mar 12, 2009 07:16
Cool, you make this too easy.  The debug file is exactly what I needed.  I had no idea what was going on and what variables where actually being sent.  Thank you for this, massive help.