home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2001 June
/
Chip_2001-06_cd1.bin
/
ctenari
/
Sery
/
setsql.asp
< prev
next >
Wrap
Text File
|
2001-04-16
|
5KB
|
157 lines
<%
Dim errmsg
function checkerr(message2)
if err.number <>0 then
errmsg= errmsg+vbCrLf+"Chyba : "+err.description
err.clear
else
if message2<>"" then
errmsg= errmsg+vbCrLf+message2
end if
end if
end function
On error resume next
if Request.Form("comp")="1" then
newfilename = Left(Request.ServerVariables ("APPL_PHYSICAL_PATH")+Request.form("database"),len(Request.ServerVariables ("APPL_PHYSICAL_PATH")+Request.form("database"))-2)+"__"
Set Engine = CreateObject("JRO.JetEngine")
if Request.form("system")>"" then
Sourcestr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Request.ServerVariables ("APPL_PHYSICAL_PATH")+Request.form("database")+";User Id="+Request.form("jmeno")+";Password="+Request.form("heslo")+";Jet OLEDB:System Database="+Request.ServerVariables ("APPL_PHYSICAL_PATH")+Request.form("system")+";Jet OLEDB:Engine Type=5"
else
if Request.form("jmeno")>"" then
Sourcestr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Request.ServerVariables ("APPL_PHYSICAL_PATH")+Request.form("database")+";User Id="+Request.form("jmeno")+";Password="+Request.form("heslo")+";Jet OLEDB:Engine Type=5"
else
Sourcestr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Request.ServerVariables ("APPL_PHYSICAL_PATH")+Request.form("database")+";Jet OLEDB:Engine Type=5"
end if
end if
Deststr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+newfilename+";Jet OLEDB:Engine Type=5"
Engine.CompactDatabase Sourcestr , Deststr
checkerr("")
Set fso = CreateObject("Scripting.FileSystemObject")
checkerr("")
fso.CopyFile newfilename, Request.ServerVariables ("APPL_PHYSICAL_PATH")+Request.form("database")
checkerr("")
fso.DeleteFile (newfilename)
checkerr("")
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>
<body>
<p align="center"><textarea rows="30" name="result" cols="89">
<%
if errmsg="" then
checkerr("Databßze byla zkomprimovßna ·sp∞Ün∞")
else
checkerr("Oprava a komprimace databßze se nezda°ila")
end if
Response.write(errmsg)
else
if (Request.form("database")<>Empty OR Request.form("dsn")<>Empty) then
set cnn4 = Server.CreateObject("ADODB.Connection")
set sql_cmd = Server.CreateObject("ADODB.Command")
set sql_rs = Server.CreateObject("ADODB.Recordset")
if (Request.form("Provider")="JET") then
With cnn4
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Jet OLEDB:System Database") = Request.ServerVariables ("APPL_PHYSICAL_PATH")+Request.form("system")
.Open Request.ServerVariables ("APPL_PHYSICAL_PATH")+Request.form("database"),Request.form("jmeno"),Request.form("heslo")
End With
checkerr("")
else
cn.Open "FILEDSN="+Request.form("dsn")
checkerr("")
end if
sql_cmd.ActiveConnection = cnn4
fp_sQry=Request.form("SQLtext")
fp_sDefault=""
fp_sNoRecords=""
fp_iMaxRecords=0
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
sql_cmd.CommandType = fp_iCommandType
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>
<body>
<p align="center"><textarea rows="30" name="result" cols="89">
<%
Do while len(fp_sQry)>0
leftpos=instr(fp_sQry,";")
fp_sQry2 = trim(left(fp_sQry,leftpos-1))
fp_sQry = trim(Mid(fp_sQry,leftpos+1))
leftpos=instr(fp_sQry,";")
if leftpos=0 then
fp_sQry =""
end if
sql_cmd.CommandText = fp_sQry2
if SQL_rs.state<>0 then
SQL_rs.close
end if
set SQL_rs.source = sql_cmd
SQL_rs.open()
checkerr("")
if (sql_rs.state<>0) then
If not(sql_rs.EOF) then
sql_rs.movefirst
Do While not sql_rs.EOF
for a=0 to sql_rs.fields.count-1
if IsNull(sql_rs.fields(a).name) then
firststr = ""
else
firststr = sql_rs.fields(a).name
end if
if IsNull(sql_rs.fields(a).value) then
sectstr = ""
else
sectstr = CStr(sql_rs.fields(a).value)
end if
if err.number <>0 then
Response.write("Chyba : "+err.description)
err.clear
else
response.write firststr +vbTab+sectstr+vbTab
end if
next
response.write vbCrLf
sql_rs.movenext
loop
end if
end if
loop
Response.write(errmsg)
%>
</textarea></p>
</body>
</html>
<%
cnn4.Close
else
response.write "Okno s v²sledky"
end if
end if
%>