I have a very simple Javascript function that gets to the MS SQL server and returns some records. There is a cell that I want to show only in the top table of the table when it is unique. I believe that my problem is var failure, because the variable that I assign in the while loop does not work, because the value is not transferred from the last records for comparison. Here is the code
function searchIndex()
{
var termcounter = "";
flyoutHTML = '<table>';
var adOpenDynamic = 2
var adLockOptimistic = 3
var conn = new ActiveXObject("ADODB.Connection");
var connectionstring = "Provider=SQLOLEDB;Server=XXXXXXXX;INTEGRATED SECURITY=SSPI;DATABASE=YYYYYYYYYY;"
conn.Open(connectionstring)
var rs = new ActiveXObject("ADODB.Recordset")
rs.Open("SELECT field1, field2, field4, field4, field5 FROM dbo.table;", conn)
if (rs.eof)
{
flyoutHTML += '<tr><td align="center">No Records Found!</td></tr>';
}
else
{
while(!rs.eof)
{
if (termcounter != rs(0))
{
var termcounter = rs(0);
flyoutHTML += '<tr>';
flyoutHTML += '<td colspan="3">' + rs(0) + '</td>';
flyoutHTML += '</tr>';
}
flyoutHTML += '<tr>';
flyoutHTML += '<td>' + rs(1) + '</td><td>' + rs(2) + '</td><td>' + rs(3) + '</td>';
flyoutHTML += '</tr>';
rs.movenext
}
rs.close
conn.close
flyoutHTML += '</table>';
}
Rick
source
share