%
DoReadTable
%>
<%
DisplayAdminDatabase
%>
<%
Sub DoReadTable()
If Request.Form("rsql") <> "" and Request.Form("database") <> "" Then
ReadTable Request.Form("rsql"), Request.Form("database")
end if
end sub
' Display database page
' IN : -
' OUT : -
Sub DisplayAdminDatabase()
Dim oCn, oRs, rSQL, iLine, X, oFolder, oFile, tabella
Dim adb, bdb, cdb, pdb, fso, fil, engine, dba, dbb, sizebef, sizeaft, sPassword
Dim valori, campo, valore
If GLOBAL_DB_TYPE = "MSACC" Then
CreateTopTable "SQLQuery", GetTranslation("LANG_DATABASE")
Response.Write GLOBAL_SITE_SUBTABLE & vbCRLF
Response.Write "
" & vbCRLF
Response.Write "
" & vbCRLF
Response.Write "
" & vbCRLF
Response.Write "
" & GetTranslation("LANG_DATABASE") & "
" & vbCRLF
Response.Write "
" & vbCRLF
Set fso = CreateObject("Scripting.FileSystemObject")
Set oFolder = fso.GetFolder(Server.MapPath(GLOBAL_SITE_DATABASE_PATH))
Response.Write " " & vbCRLF
Response.Write "
" & vbCRLF
Response.Write "" & vbCRLF
CreateBottomTable ""
Else
CreateTable "Access", "", "Need MSAccess db", ""
End If
end sub
Function ReadTable(nome, dbase)
Dim oCn, oFs, oRs, oFile, rSQL, nomi, valori, campo, valore
Set oCn = DBConnexion(dbase)
Set oFs = Server.CreateObject("Scripting.FileSystemObject")
Set oFile = oFs.OpenTextFile(Server.MapPath(GLOBAL_SITE_DATABASE_PATH) & "\" & nome & ".sql", 2, True)
'http://www.w3schools.com/ado/ado_datatypes.asp
'copy table
rSQL = "SELECT * FROM " & nome
Set oRs = DBRecordSet(oCn, rSQL)
rSQL = "DELETE FROM " & nome & ";" & vbCRLF
oFile.Write rSQL
'on error resume next
do while Not oRs.EOF
nomi = "("
valori = "("
for each campo in oRs.fields
valore = campo.value
'string
if campo.type = 202 then
valore = NormString(campo.value)
end if
if campo.type >= 203 then
valore = NormMemo(valore)
end if
'date
if campo.type = 7 then
valore = NormDate(campo.value)
end if
'integer
if campo.type = 2 then
valore = NormNumber(campo.value)
end if
'long
if campo.type = 3 then
valore = NormNumber(campo.value)
end if
'boolean
if campo.type = 11 then
valore = NormBoolean(campo.value)
end if
if nomi = "(" then
nomi = nomi & campo.name
else
nomi = nomi & ", " & campo.name
end if
if valori = "(" then
valori = valori & valore
else
valori = valori & ", " & valore
end if
next
rSQL = "INSERT INTO " & nome & " " & nomi & ") VALUES " & valori & ");" & vbCRLF
oFile.Write rSQL
oRs.movenext
loop
on error goto 0
oRs.close
Set oRs = Nothing
oFile.Close
Set oFile = nothing
Set oFs = nothing
oCn.Close
Set oCn = Nothing
End Function
Function NormMemo(sText)
If sText <> "" Then
sText = replace(sText, "<", "<",1,-1,1)
sText = replace(sText, ">", ">",1,-1,1)
sText = replace(sText, "'", "\'",1,-1,1)
End If
sText = "'" & sText & "'"
NormMemo = sText
End Function
%>