hey all...
i'm retrieving a recordset via javascript and ado. the ado method i am using is getstring. i am used to server side code...and i was wondering why i cannot get a string returned by getstring to work correctly in the following:
if i write out the value of var myData and 'hard code' into the code it works;
however...returning as a recordset...although it populates the grid...it populates the grid with ["Wmt","Walmart","10","10","joe"] in each cell
...thanks
i'm retrieving a recordset via javascript and ado. the ado method i am using is getstring. i am used to server side code...and i was wondering why i cannot get a string returned by getstring to work correctly in the following:
Code:
<script>
var sDatabasePath = "tree.mdb";
var cn = new ActiveXObject("ADODB.Connection");
var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + sDatabasePath;
cn.Open(strConn);
var rs = new ActiveXObject("ADODB.Recordset");
var SQL = "select Ticker, [Company Name], [Market Cap], Sales, Employees from tblMarket";
rs.Open(SQL, cn,2,3);
if(!rs.eof)
{
var sRecs = '["' + rs.GetString(2,-1,'","','"],["',' ');
var s = String(sRecs).substring(0,String(sRecs).length-3)
}
var myData = [
s
];
var myColumns = [
"Ticker", "Company Name", "Market Cap.", "$ Sales", "Employees"
];
</script>
</head>
<body>
<script>
// create ActiveWidgets Grid javascript object
var obj = new AW.UI.Grid;
obj.setId("myGrid");
// define data formats
var str = new AW.Formats.String;
var num = new AW.Formats.Number;
obj.setCellFormat([str, str, str, str, str]);
// provide cells and headers text
obj.setCellText(s);
obj.setHeaderText(myColumns);
// set number of rows/columns
obj.setRowCount(20);
obj.setColumnCount(5);
// enable row selectors
obj.setSelectorVisible(true);
obj.setSelectorText(function(i){return this.getRowPosition(i)+1});
// set headers width/height
obj.setSelectorWidth(28);
obj.setHeaderHeight(20);
// set row selection
obj.setSelectionMode("single-row");
// set click action handler
obj.onCellClicked = function(event, col, row){window.status = this.getCellText(col, row)};
// write grid html to the page
document.write(obj);
</script>
if i write out the value of var myData and 'hard code' into the code it works;
Code:
var myData = [
["Wmt","Walmart","10","10","joe"]
];
however...returning as a recordset...although it populates the grid...it populates the grid with ["Wmt","Walmart","10","10","joe"] in each cell
...thanks