Greetings,
I am looking for a way to list the field or column names of a table. i have found several examples using VBscript, but I need to do this using JScript or Javascript.
Here is what I have. (converted from a working sample in vbscript)
<%
var rsjsConn = Server.CreateObject("ADODB.Connection"
rsjsConn.Open(MM_forums_STRING);
rsjs = rsjsConn.Execute("select * from FORUM_FORUM"
var columnTypes = new Array(205)
columnTypes[0] = "Empty"
columnTypes[2] = "SmallInt"
columnTypes[3] = "Integer"
columnTypes[4] = "Real"
columnTypes[5] = "Double"
columnTypes[6] = "Currency"
columnTypes[7] = "Date"
columnTypes[8] = "BSTR"
columnTypes[9] = "IDispatch"
columnTypes[10] = "Error Code"
columnTypes[11] = "Boolean"
columnTypes[12] = "Variant"
columnTypes[13] = "IUnknown"
columnTypes[14] = "Decimal"
columnTypes[16] = "TinyInt"
columnTypes[17] = "Unsigned TinyInt (BYTE)"
columnTypes[18] = "Unsigned Small Int (WORD)"
columnTypes[19] = "Unsigned Int (DWORD)"
columnTypes[20] = "BigInt"
columnTypes[21] = "Unsigned Big Int"
columnTypes[64] = "FileTime"
columnTypes[72] = "Unique Identifier (GUID)"
columnTypes[128] = "Binary"
columnTypes[129] = "Char"
columnTypes[130] = "nChar"
columnTypes[131] = "Numeric"
columnTypes[132] = "User Defined (UDT)"
columnTypes[133] = "DBDate"
columnTypes[134] = "DBTime"
columnTypes[135] = "SmallDateTime"
columnTypes[136] = "Chapter"
columnTypes[138] = "Automation (PropVariant)"
columnTypes[139] = "VarNumeric"
columnTypes[200] = "VarChar"
columnTypes[201] = "Text"
columnTypes[202] = "nVarChar"
columnTypes[203] = "nText"
columnTypes[204] = "VarBinary"
columnTypes[205] = "Image"
Response.Write("list should start here" )
for (column in rsjs.Fields){
Response.Write(column .Fields.Name + " [" + columnTypes[column .Fields.Type])
ct = column .Fields.Type
if (ct ==129 || ct == 130 || ct == 200 || ct == 202){
// definedSize only works in SQL Server
Response.write(" (" + column .Fields.definedSize + "" )
}
Response.Write("]<br>" )
}
%>
Problem is that the list is not created.
I also commented out the for/in loop to run only the inner statement like this :
Response.Write(rsjs.Fields.Name + " [" + columnTypes[rsjs.Fields.Type])
ct = rsjs.Fields.Type
if (ct ==129 || ct == 130 || ct == 200 || ct == 202){
// definedSize only works in SQL Server
Response.write(" (" + rsjs.Fields.definedSize + "" )
}
Response.Write("]<br>" )
Both rsjs.Fields.Name and rsjs.Fields.Type return "undefined" in the output.
Have I missed something?
I am looking for a way to list the field or column names of a table. i have found several examples using VBscript, but I need to do this using JScript or Javascript.
Here is what I have. (converted from a working sample in vbscript)
<%
var rsjsConn = Server.CreateObject("ADODB.Connection"
rsjsConn.Open(MM_forums_STRING);
rsjs = rsjsConn.Execute("select * from FORUM_FORUM"
var columnTypes = new Array(205)
columnTypes[0] = "Empty"
columnTypes[2] = "SmallInt"
columnTypes[3] = "Integer"
columnTypes[4] = "Real"
columnTypes[5] = "Double"
columnTypes[6] = "Currency"
columnTypes[7] = "Date"
columnTypes[8] = "BSTR"
columnTypes[9] = "IDispatch"
columnTypes[10] = "Error Code"
columnTypes[11] = "Boolean"
columnTypes[12] = "Variant"
columnTypes[13] = "IUnknown"
columnTypes[14] = "Decimal"
columnTypes[16] = "TinyInt"
columnTypes[17] = "Unsigned TinyInt (BYTE)"
columnTypes[18] = "Unsigned Small Int (WORD)"
columnTypes[19] = "Unsigned Int (DWORD)"
columnTypes[20] = "BigInt"
columnTypes[21] = "Unsigned Big Int"
columnTypes[64] = "FileTime"
columnTypes[72] = "Unique Identifier (GUID)"
columnTypes[128] = "Binary"
columnTypes[129] = "Char"
columnTypes[130] = "nChar"
columnTypes[131] = "Numeric"
columnTypes[132] = "User Defined (UDT)"
columnTypes[133] = "DBDate"
columnTypes[134] = "DBTime"
columnTypes[135] = "SmallDateTime"
columnTypes[136] = "Chapter"
columnTypes[138] = "Automation (PropVariant)"
columnTypes[139] = "VarNumeric"
columnTypes[200] = "VarChar"
columnTypes[201] = "Text"
columnTypes[202] = "nVarChar"
columnTypes[203] = "nText"
columnTypes[204] = "VarBinary"
columnTypes[205] = "Image"
Response.Write("list should start here" )
for (column in rsjs.Fields){
Response.Write(column .Fields.Name + " [" + columnTypes[column .Fields.Type])
ct = column .Fields.Type
if (ct ==129 || ct == 130 || ct == 200 || ct == 202){
// definedSize only works in SQL Server
Response.write(" (" + column .Fields.definedSize + "" )
}
Response.Write("]<br>" )
}
%>
Problem is that the list is not created.
I also commented out the for/in loop to run only the inner statement like this :
Response.Write(rsjs.Fields.Name + " [" + columnTypes[rsjs.Fields.Type])
ct = rsjs.Fields.Type
if (ct ==129 || ct == 130 || ct == 200 || ct == 202){
// definedSize only works in SQL Server
Response.write(" (" + rsjs.Fields.definedSize + "" )
}
Response.Write("]<br>" )
Both rsjs.Fields.Name and rsjs.Fields.Type return "undefined" in the output.
Have I missed something?