[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Dumb questions from a newbie


Subject: RE: [xsl] Dumb questions from a newbie
From: "Steve Renshaw" <renshaw_steve@xxxxxxxxxxx>
Date: Wed, 12 Dec 2001 11:17:28 +0000

Is ths what you intended? I get error

"Microsoft JScript runtime error Type mismatch line = 29, col = 12 (line is offset from the start of the script block). Error returned from property or method call.'"


function GetRecords(connection, tablename) { var output; var conn = new ActiveXObject("ADODB.Connection"); var cmd = new ActiveXObject("ADODB.Command"); var rs = new ActiveXObject("ADODB.Recordset"); var Err, ErrCount, fPos; var tdom = new ActiveXObject("MSXML2.FreeThreadedDOMDocument"); var od = tdom.createNode(1, 'myDAO', '');

     conn.Open(connection);
     cmd.CommandText = "SELECT * FROM " + tablename;
     cmd.ActiveConnection = conn;
     rs = cmd.Execute();
     ErrCount = conn.errors.count;
     if(ErrCount > 0){
       for(Err = 0; Err < ErrCount; Err++){
          output += conn.errors.item(Err);
       }
     }
     else{
       output += "\n";
      	while (!rs.EOF) {
        var row = tdom.createNode(1, 'row', '');
	        row = od.appendChild(row);

        for (var fPos = 0; fPos < rs.fields.count; fPos++) {
           row.setAttribute(rs.fields(fPos).name,rs.fields(fPos).value);
        }
        rs.MoveNext;
       }
       return od.selectNodes("*");
     }
 }



From: "Chris Bayes" <chris@xxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: RE: [xsl] Dumb questions from a newbie
Date: Wed, 12 Dec 2001 01:04:25 -0000

Ivan,
You can get around the d-o-e if you return a node-set i.e.
{
var tdom = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
var od = tdom.createNode(1, 'myDAO', '');
...
	while (!rs.EOF){
         var row = tdom.createNode(1, 'row', '');
	   row = od.appendChild(row);
         for (var fPos = 0; fPos < rs.fields.count; fPos++){
            row.setAttribute(rs.fields(fPos).name,
rs.fields(fPos).value);
         }
         rs.MoveNext;
      }
      return od.selectNodes("*");
}
It also means that you can use the result of a query as a full xslt
node-set in a variable/apply-templates/for-each et al.

Ciao Chris

XML/XSL Portal
http://www.bayes.co.uk/xml


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list




_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list




Current Thread
Keywords