home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 June / Chip_2001-06_cd1.bin / ctenari / Sery / setsql.asp < prev    next >
Text File  |  2001-04-16  |  5KB  |  157 lines

  1. <%
  2. Dim errmsg
  3. function checkerr(message2)
  4.      if err.number <>0 then
  5.           errmsg= errmsg+vbCrLf+"Chyba : "+err.description
  6.           err.clear
  7.       else    
  8.           if message2<>"" then
  9.               errmsg= errmsg+vbCrLf+message2
  10.           end if    
  11.     end if
  12. end function    
  13. On error resume next
  14. if Request.Form("comp")="1" then
  15.      newfilename = Left(Request.ServerVariables ("APPL_PHYSICAL_PATH")+Request.form("database"),len(Request.ServerVariables ("APPL_PHYSICAL_PATH")+Request.form("database"))-2)+"__"
  16.      Set Engine = CreateObject("JRO.JetEngine")
  17.      if Request.form("system")>"" then
  18.          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"
  19.      else
  20.          if Request.form("jmeno")>"" then
  21.              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"
  22.          else
  23.              Sourcestr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Request.ServerVariables ("APPL_PHYSICAL_PATH")+Request.form("database")+";Jet OLEDB:Engine Type=5"
  24.         end if    
  25.     end if
  26.      Deststr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+newfilename+";Jet OLEDB:Engine Type=5"
  27.      Engine.CompactDatabase Sourcestr , Deststr 
  28.     checkerr("")
  29.      Set fso = CreateObject("Scripting.FileSystemObject") 
  30.      checkerr("")
  31.     fso.CopyFile newfilename, Request.ServerVariables ("APPL_PHYSICAL_PATH")+Request.form("database")
  32.     checkerr("")
  33.     fso.DeleteFile (newfilename)
  34.     checkerr("")
  35. %>
  36. <html>
  37.  
  38. <head>
  39. <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
  40. <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
  41. <meta name="ProgId" content="FrontPage.Editor.Document">
  42. <title>New Page 1</title>
  43. </head>
  44.  
  45. <body>
  46.  
  47. <p align="center"><textarea rows="30" name="result" cols="89">
  48. <% 
  49. if errmsg="" then
  50.     checkerr("Databßze byla zkomprimovßna ·sp∞Ün∞")
  51. else
  52.     checkerr("Oprava a komprimace databßze se nezda°ila")
  53. end if    
  54. Response.write(errmsg)
  55. else
  56. if (Request.form("database")<>Empty  OR Request.form("dsn")<>Empty) then
  57. set cnn4                 = Server.CreateObject("ADODB.Connection")
  58. set sql_cmd                 = Server.CreateObject("ADODB.Command")
  59. set sql_rs                = Server.CreateObject("ADODB.Recordset")
  60. if (Request.form("Provider")="JET") then
  61.     With cnn4
  62.            .Provider = "Microsoft.Jet.OLEDB.4.0"
  63.           .Properties("Jet OLEDB:System Database") = Request.ServerVariables ("APPL_PHYSICAL_PATH")+Request.form("system")
  64.           .Open Request.ServerVariables ("APPL_PHYSICAL_PATH")+Request.form("database"),Request.form("jmeno"),Request.form("heslo")
  65.     End With 
  66.     checkerr("")
  67. else
  68.     cn.Open  "FILEDSN="+Request.form("dsn")
  69.     checkerr("")
  70. end if
  71. sql_cmd.ActiveConnection  = cnn4
  72. fp_sQry=Request.form("SQLtext")
  73. fp_sDefault=""
  74. fp_sNoRecords=""
  75. fp_iMaxRecords=0
  76. fp_iCommandType=1
  77. fp_iPageSize=0
  78. fp_fTableFormat=True
  79. fp_fMenuFormat=False
  80. fp_sMenuChoice=""
  81. fp_sMenuValue=""
  82. fp_fCustomQuery=True
  83. BOTID=0
  84. fp_iRegion=BOTID
  85. sql_cmd.CommandType = fp_iCommandType
  86. %>
  87. <html>
  88.  
  89. <head>
  90. <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
  91. <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
  92. <meta name="ProgId" content="FrontPage.Editor.Document">
  93. <title>New Page 1</title>
  94. </head>
  95.  
  96. <body>
  97.  
  98. <p align="center"><textarea rows="30" name="result" cols="89">
  99. <%
  100. Do while len(fp_sQry)>0
  101. leftpos=instr(fp_sQry,";")
  102. fp_sQry2 = trim(left(fp_sQry,leftpos-1))
  103. fp_sQry = trim(Mid(fp_sQry,leftpos+1))
  104. leftpos=instr(fp_sQry,";")
  105. if leftpos=0 then 
  106.     fp_sQry =""
  107. end if    
  108. sql_cmd.CommandText = fp_sQry2
  109. if SQL_rs.state<>0 then 
  110.     SQL_rs.close
  111. end if    
  112. set SQL_rs.source = sql_cmd
  113. SQL_rs.open()
  114. checkerr("")
  115.  if (sql_rs.state<>0)  then
  116. If  not(sql_rs.EOF) then
  117. sql_rs.movefirst
  118. Do While not sql_rs.EOF
  119. for a=0 to sql_rs.fields.count-1
  120.     if   IsNull(sql_rs.fields(a).name) then
  121.         firststr = ""
  122.     else    
  123.         firststr = sql_rs.fields(a).name
  124.     end if    
  125.     if  IsNull(sql_rs.fields(a).value) then
  126.         sectstr = ""
  127.     else    
  128.         sectstr = CStr(sql_rs.fields(a).value)
  129.     end if        
  130.     if err.number <>0 then
  131.           Response.write("Chyba : "+err.description)    
  132.           err.clear
  133.     else 
  134.         response.write firststr +vbTab+sectstr+vbTab
  135.     end if        
  136. next
  137. response.write vbCrLf
  138.     sql_rs.movenext    
  139.     loop
  140. end if    
  141. end if
  142. loop
  143. Response.write(errmsg)
  144.     %>
  145. </textarea></p>
  146.  
  147. </body>
  148.  
  149. </html>
  150. <%
  151. cnn4.Close
  152. else
  153.     response.write "Okno s v²sledky"
  154. end if
  155. end if
  156. %>
  157.