jason_kelly
01-25-2012, 06:05 PM
Hi There,
I really need your help.
How could I amend the following code below to incorporate the fieldnames on the top before displaying the values of the recordset?
Ie.
[FIELDNAME1] [FIELDNAME2] [FIELDNAME3] [FIELDNAME4]
value1 value2 value3 value4
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<script language="javascript" type="text/javascript">
function getsqltable() {
var strtable = ""
var cn = new ActiveXObject("ADODB.Connection")
var rs = new ActiveXObject("ADODB.Recordset")
var dbfile = "imts.mdb"
var dbPath = "F:/PROJECTS/IMTS PROJECT/V7/database/"
cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " + dbPath + dbfile + "")
var mySQL = "SELECT * FROM tbl_imts WHERE [File Number] = 'A-2010-00301'"
rs.Open(mySQL, cn, 1, 3)
rs.MoveFirst
strtable='<table cellpadding=0 cellspacing=0 width=75%>';
while (!rs.eof)
{
strtable+='<tr>';
strtable+='<td>'+rs.fields(0)+'</td>' + '<td>'+rs.fields(1)+'</td>' + '<td>'+rs.fields(2)+'</td>' + '<td>'+rs.fields(3)+'</td>'
strtable+='</tr>';
rs.movenext;
}
strtable+='</table>';
rs.close;
cn.close;
document.getElementById('htmltable').innerHTML=strtable;
}
</script>
</head>
<body>
<input type="button" onclick="getsqltable();" value="Click Me"/>
<div id="htmltable"></div>
</body>
</html>
I've tried modifying the while codemyself, but it puts it all on one line:
while (!rs.eof)
{
strtable+='<tr>';
strtable+='<td>'+rs.fields(0).Name+'</td>' + '<td>'+rs.fields(1).Name+'</td>' + '<td>'+rs.fields(2).Name+'</td>' + '<td>'+rs.fields(3).Name+'</td>'
strtable+='<td>'+rs.fields(0)+'</td>' + '<td>'+rs.fields(1)+'</td>' + '<td>'+rs.fields(2)+'</td>' + '<td>'+rs.fields(3)+'</td>'
strtable+='</tr>';
rs.movenext;
}
any ideas?
Much thanks and appreciation for everyones help.
Cheers and much thanks in advance,
Jay
I really need your help.
How could I amend the following code below to incorporate the fieldnames on the top before displaying the values of the recordset?
Ie.
[FIELDNAME1] [FIELDNAME2] [FIELDNAME3] [FIELDNAME4]
value1 value2 value3 value4
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<script language="javascript" type="text/javascript">
function getsqltable() {
var strtable = ""
var cn = new ActiveXObject("ADODB.Connection")
var rs = new ActiveXObject("ADODB.Recordset")
var dbfile = "imts.mdb"
var dbPath = "F:/PROJECTS/IMTS PROJECT/V7/database/"
cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " + dbPath + dbfile + "")
var mySQL = "SELECT * FROM tbl_imts WHERE [File Number] = 'A-2010-00301'"
rs.Open(mySQL, cn, 1, 3)
rs.MoveFirst
strtable='<table cellpadding=0 cellspacing=0 width=75%>';
while (!rs.eof)
{
strtable+='<tr>';
strtable+='<td>'+rs.fields(0)+'</td>' + '<td>'+rs.fields(1)+'</td>' + '<td>'+rs.fields(2)+'</td>' + '<td>'+rs.fields(3)+'</td>'
strtable+='</tr>';
rs.movenext;
}
strtable+='</table>';
rs.close;
cn.close;
document.getElementById('htmltable').innerHTML=strtable;
}
</script>
</head>
<body>
<input type="button" onclick="getsqltable();" value="Click Me"/>
<div id="htmltable"></div>
</body>
</html>
I've tried modifying the while codemyself, but it puts it all on one line:
while (!rs.eof)
{
strtable+='<tr>';
strtable+='<td>'+rs.fields(0).Name+'</td>' + '<td>'+rs.fields(1).Name+'</td>' + '<td>'+rs.fields(2).Name+'</td>' + '<td>'+rs.fields(3).Name+'</td>'
strtable+='<td>'+rs.fields(0)+'</td>' + '<td>'+rs.fields(1)+'</td>' + '<td>'+rs.fields(2)+'</td>' + '<td>'+rs.fields(3)+'</td>'
strtable+='</tr>';
rs.movenext;
}
any ideas?
Much thanks and appreciation for everyones help.
Cheers and much thanks in advance,
Jay