Grid does not load - error Expected ']'
Ok my grid won't load,
Heres my code;
<%@ LANGUAGE = VBscript %>
<%
Dim oConnection
Dim oRecordset
Set oConnection = Server.CreateObject("ADODB.Connection")
oConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("vcms.mdb")
Set oRecordset = oConnection.Execute("SELECT DISTINCT volunteers.vid, volunteers.lname, volunteers.fname, volunteers.vdphone, volunteers.vephone, volunteers.vemail, volunteers.assigned, volunteers.date_assigned, volunteers.contacted, volunteers.vaddress, volunteers.vapt, volunteers.vcity, volunteers.vcounty, volunteers.vstate, volunteers.vzip, volunteers.spt, volunteers.lpc, volunteers.fund, volunteers.scomp, volunteers.inc, volunteers.vdob, volunteers.esname, volunteers.occ, volunteers.esaddress, volunteers.escity, volunteers.esstate, volunteers.eszip, volunteers.egroup, volunteers.ecname, volunteers.ecrel, volunteers.ecphone, volunteers.cont_by, volunteers.dofi, volunteers.vssn, legal.b_check, legal.bstatus, legal.pdate_sub, legal.r FROM (SELECT * FROM (SELECT volunteers.*, interest.*, legal.*, committee.*, certs.*, coach.* FROM ((((volunteers INNER JOIN interest ON volunteers.vid = interest.vid) INNER JOIN legal ON volunteers.vid = legal.vid) LEFT JOIN committee ON volunteers.vid = committee.vid) LEFT JOIN certs ON volunteers.vid = certs.vid) LEFT JOIN coach ON volunteers.vid = coach.vid)) WHERE NOT (bstatus = 'Denied') AND NOT(bstatus = 'Inactive')")
function aw_string(s)
rem s = Replace(s, "\", "\\")
rem s = Replace(s, """", "\""") 'replace javascript control characters - ", \
rem s = Replace(s, vbCr, "\r")
rem s = Replace(s, vbLf, "\n")
aw_string = """" & s & """"
end function
function aw_headers(oRecordset)
Dim i, count, headers()
count = oRecordset.fields.count
ReDim headers(count-1)
For i=0 to count-1
headers(i) = aw_string(oRecordset(i).name)
Next
Response.write("[" & Join(headers, ", ") & "];")
end function
function aw_cells(oRecordset)
Dim i, col_count, row_count, columns(), rows()
row_count = 0
col_count = oRecordset.fields.count
ReDim columns(col_count-1)
Do while (Not oRecordset.eof)
For i=0 to col_count-1
columns(i) = aw_string(oRecordset(i))
Next
ReDim preserve rows(row_count)
rows(row_count) = vbTab & "[" & Join(columns, ", ") & "]"
row_count = row_count + 1
oRecordset.MoveNext
Loop
Response.write("[" & vbNewLine & Join(rows, "," & vbNewLine) & vbNewLine & "];" & vbNewLine)
end function
%>
<html>
<head>
<script src="../../runtime/lib/aw.js"></script>
<link href="../../runtime/styles/xp/aw.css" rel="stylesheet"></link>
</head>
<body>
<style>
</style>
<script>
// insert javascript arrays produced by ASP functions
var myHeaders = <%= aw_headers(oRecordset) %>
var myCells = <%= aw_cells(oRecordset) %>
// create grid control
var obj = new AW.UI.Grid;
// set grid text
obj.setHeaderText(myHeaders);
obj.setCellText(myCells);
// set number of columns/rows
obj.setColumnCount(myHeaders.length);
obj.setRowCount(myCells.length);
// write grid to the page
document.write(obj);
</script>
</body>
</html>
<%
oRecordset.close
oConnection.close
%>
it throws a javascript error "Expected ']'"
Heres my code;
<%@ LANGUAGE = VBscript %>
<%
Dim oConnection
Dim oRecordset
Set oConnection = Server.CreateObject("ADODB.Connection")
oConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("vcms.mdb")
Set oRecordset = oConnection.Execute("SELECT DISTINCT volunteers.vid, volunteers.lname, volunteers.fname, volunteers.vdphone, volunteers.vephone, volunteers.vemail, volunteers.assigned, volunteers.date_assigned, volunteers.contacted, volunteers.vaddress, volunteers.vapt, volunteers.vcity, volunteers.vcounty, volunteers.vstate, volunteers.vzip, volunteers.spt, volunteers.lpc, volunteers.fund, volunteers.scomp, volunteers.inc, volunteers.vdob, volunteers.esname, volunteers.occ, volunteers.esaddress, volunteers.escity, volunteers.esstate, volunteers.eszip, volunteers.egroup, volunteers.ecname, volunteers.ecrel, volunteers.ecphone, volunteers.cont_by, volunteers.dofi, volunteers.vssn, legal.b_check, legal.bstatus, legal.pdate_sub, legal.r FROM (SELECT * FROM (SELECT volunteers.*, interest.*, legal.*, committee.*, certs.*, coach.* FROM ((((volunteers INNER JOIN interest ON volunteers.vid = interest.vid) INNER JOIN legal ON volunteers.vid = legal.vid) LEFT JOIN committee ON volunteers.vid = committee.vid) LEFT JOIN certs ON volunteers.vid = certs.vid) LEFT JOIN coach ON volunteers.vid = coach.vid)) WHERE NOT (bstatus = 'Denied') AND NOT(bstatus = 'Inactive')")
function aw_string(s)
rem s = Replace(s, "\", "\\")
rem s = Replace(s, """", "\""") 'replace javascript control characters - ", \
rem s = Replace(s, vbCr, "\r")
rem s = Replace(s, vbLf, "\n")
aw_string = """" & s & """"
end function
function aw_headers(oRecordset)
Dim i, count, headers()
count = oRecordset.fields.count
ReDim headers(count-1)
For i=0 to count-1
headers(i) = aw_string(oRecordset(i).name)
Next
Response.write("[" & Join(headers, ", ") & "];")
end function
function aw_cells(oRecordset)
Dim i, col_count, row_count, columns(), rows()
row_count = 0
col_count = oRecordset.fields.count
ReDim columns(col_count-1)
Do while (Not oRecordset.eof)
For i=0 to col_count-1
columns(i) = aw_string(oRecordset(i))
Next
ReDim preserve rows(row_count)
rows(row_count) = vbTab & "[" & Join(columns, ", ") & "]"
row_count = row_count + 1
oRecordset.MoveNext
Loop
Response.write("[" & vbNewLine & Join(rows, "," & vbNewLine) & vbNewLine & "];" & vbNewLine)
end function
%>
<html>
<head>
<script src="../../runtime/lib/aw.js"></script>
<link href="../../runtime/styles/xp/aw.css" rel="stylesheet"></link>
</head>
<body>
<style>
</style>
<script>
// insert javascript arrays produced by ASP functions
var myHeaders = <%= aw_headers(oRecordset) %>
var myCells = <%= aw_cells(oRecordset) %>
// create grid control
var obj = new AW.UI.Grid;
// set grid text
obj.setHeaderText(myHeaders);
obj.setCellText(myCells);
// set number of columns/rows
obj.setColumnCount(myHeaders.length);
obj.setRowCount(myCells.length);
// write grid to the page
document.write(obj);
</script>
</body>
</html>
<%
oRecordset.close
oConnection.close
%>
it throws a javascript error "Expected ']'"
Scottie
January 25,