how to populate grid from recordset javascript
I am using JavaScript
I have connected to oracle
run query
now I need populate grid from recordset
please help me
thanks
tornado
October 4,
Antony
here is my script
could you please look and advice what's wrong
thanks
<script type="text/javascript">
var conObj = new ActiveXObject('ADODB.Connection');
var connectionString = "Driver={Microsoft ODBC for Oracle};CONNECTSTRING=orcl.com;uid=wibstar;pwd=qwerty;"
conObj.Open(connectionString);
var rs = new ActiveXObject("ADODB.Recordset");
rs.Open("select name, lastname from users", conObj);
if(!rs.eof)
{
sRec=rs.GetString(2,-1,",","\n"," ");
myData = sRecs.split(/\n/);
for (var i=0; i<aRec.length; i++)
{
myData[i]=myData[i].split(/,/);
}
}
var myData = [
s
];
var myColumns = [
"name", "lastName"
];
</script>
</head>
<body>
<script type="text/javascript">
var obj = new AW.UI.Grid;
obj.setId("myGrid");
var str = new AW.Formats.String;
var num = new AW.Formats.Number;
obj.setCellFormat([str, str]);
obj.setCellText(s);
obj.setHeaderText(myColumns);
obj.setRowCount(myData.length);
obj.setColumnCount(myColumns.length);
obj.setSelectorVisible(true);
obj.setSelectorText(function(i){return this.getRowPosition(i)+1});
obj.setSelectorWidth(28);
obj.setHeaderHeight(20);
obj.setSelectionMode("single-row");
obj.onCellClicked = function(event, col, row){window.status = this.getCellText(col, row)};
document.write(obj);
rs.close;
</script>
tornado
October 5,
or please advice recordset into a js array for the variable myData
thanks in advance
tornado
October 5,
I don't know how your ActiveX code works. Should that be in the HTML head section rather than the body?
You can view the page source after running it to see if your myData array gets populated. If its not, then the ActiveX code you have either isn't populating it or your SQL isn't returning a result.
Anthony
October 5,