%@Language=VBScript %>
<%
' Create a connection object
Set Conn = Server.CreateObject ("ADODB.Connection")
dim CN()
'pathname = "\powerlearn\db"
'Response.write server.MapPath(pathname)
'set fso = server.CreateObject("scripting.FileSystemObject")
' Open the connection to the database. I use a system DSN here, but
' you can use whatever method you wish
conn.Open("DSN=powerlearn; UID=powerlearn; PWD=gfry6g;")
' Open the database schema to query the list of tables. Extract the
' list in a Recordset object
'sqlQuery="select * from variable_table"
'set rsbuffer=conn.Execute(sqlQuery)
'Response.write RSbuffer.getString
Set Rs = Conn.OpenSchema (adSchemaColumns)
' Loop through the list and print the table names
With rs
lFieldCount = .Fields.Count - 1
'On Error Resume Next
.MoveFirst
'On Error GoTo ErrorHandler
tablename= ""
columnCount=0
Do While Not .EOF
For lCtr = 0 To lFieldCount
Set oField = .Fields(lCtr)
If lCtr < lFieldCount Then
if oField.Name="TABLE_NAME" and oField.value<>tablename then
if tablename<> "" and inStr(1,tablename,"sys",vbTextCompare) = 0 and inStr(1,tablename,"CONSTRAINT",vbTextCompare) = 0 and inStr(1,tablename,"COLUMN",vbTextCompare) = 0 and inStr(1,tablename,"DOMAIN",vbTextCompare) = 0 and inStr(1,tablename,"SCHEMATA",vbTextCompare) = 0 and inStr(1,tablename,"privileges",vbTextCompare) = 0 and tablename <>"TABLES" and inStr(1,tablename,"USAGE",vbTextCompare) = 0 then
'dont do at initial reading
'if tablename changes then execute sqlQuery
sqlQuery = "select * from "&tablename
'Response.Write sqlQuery&"
"
set RSbuffer = conn.Execute(sqlQuery)
'set ts = fso.openTextFile(server.mapPath(pathname)&filename,2,true)
Response.Write "
"
'for i=1 to columnCount
' Response.Write CN(i)&"|"
'next
do while Not RSbuffer.EOF
'write all the values in all column
for i=1 to columnCount
Response.Write RSbuffer(CN(i))&"|"
next
Response.Write "
"
RSbuffer.moveNext
loop
else
tableName = oField.value
filename=tablename&".txt"
'Response.Write fileName&"
"
end if
tableName = oField.value
filename=tablename&".txt"
Response.write "
"&tableName&"
"
columnCount=0
end if
if oField.Name = "COLUMN_NAME" then
Response.write oField.Value&"|"
'prepare the next container in array
columnCount=columnCount+1
redim preserve CN(columnCount)
'save the column name at array
CN(columnCount) = oField.Value
end if
Else
if oField.Name = "COLUMN_NAME" or oField.Name="TABLE_NAME" or oField.Name="COLUMN_HASDEFAULT" then
Response.Write oField.Name & ": " & oField.Value
end if
End If
Next
.MoveNext
Loop
End With
' Close and destroy the recordset and connection objects
Rs.Close
Set Rs = Nothing
Conn.Close
Set Conn = Nothing
%>