<% call copyrightnotice() Dim postBack,validData:validData=true Dim datastore, dbUser, dbPass, dbName, dbServer, body, objCon, objRS, loadType, hostfile, arrRS,sspi,errored:errored = false Dim percentage:percentage = 0 Dim nstart:nstart = timer() Dim objPGDUpload Set objPGDUpload = new PGDUpload objPGDUpload.sizelimit = 500*1024 if objPGDUpload.getform then postBack = true else postBack = false if postBack and objPGDUpload.count > 0 then if objPGDUpload.form("debug")("Value")&""="on" then Dim item for each item in objPGDUpload.forms response.write (item("name")&" ("&iff(item("isBinary"),"Binary","Texture")&"): "&_ iff(item("isBinary"),item("filename")&_ " ("&item("FileExt")&"); (MIME: "&item("ContentType")&")",item("Value"))&"
") next end if if not validReferer() then response.end dbUser = objPGDUpload.form("dbUser")("Value")&"" dbPass = objPGDUpload.form("dbPass")("Value")&"" dbName = objPGDUpload.form("dbName")("Value")&"" dbServer = objPGDUpload.form("dbServer")("Value")&"" sspi = objPGDUpload.form("sspi")("Value")&"" if len(trim(dbName)) = 0 or len(trim(dbServer)) = 0 then validData = false end if Dim datastoreTmp(1) datastoreTmp(0) = "Provider=SQLOLEDB; Data Source=#dbServer#; Initial Catalog=#dbName#; Integrated Security=SSPI;" datastoreTmp(1) = "Provider=SQLOLEDB; Data Source=#dbServer#; Initial Catalog=#dbName#; User ID=#dbUser#; Password=#dbPass#;" if sspi="on" then datastore = replace(datastoreTmp(0),"#dbServer#",dbServer) else datastore = replace(datastoreTmp(1),"#dbServer#",dbServer) end if datastore = replace(datastore,"#dbName#",dbName) datastore = replace(datastore,"#dbUser#",dbUser) datastore = replace(datastore,"#dbPass#",dbPass) on error resume next Dim ScriptTimeout ScriptTimeout = objPGDUpload.form("scripttimeout")("Value")&"" if isNumeric(ScriptTimeout) then ScriptTimeout = cint(ScriptTimeout) else ScriptTimeout=20 end if if ScriptTimeout<=0 then ScriptTimeout = 20 Server.ScriptTimeout = ScriptTimeout SET objCon = server.createObject("ADODB.connection") with objCon .open datastore .close end with Set objCon = nothing if err.number <> 0 then validData = false if validData then Dim reportq,failsafe,syntax,saveoption,deleteoption reportq = objPGDUpload.form("reportq")("Value")&"" loadType = objPGDUpload.form("loadType")("Value")&"" hostfile = objPGDUpload.form("hostfile")("Value")&"" failsafe = objPGDUpload.form("failsafe")("Value")&"" syntax = objPGDUpload.form("syntax")("Value")&"" saveoption = objPGDUpload.form("saveoption")("Value")&"" deleteoption = objPGDUpload.form("deleteoption")("Value")&"" if loadType = "local" then if objPGDUpload.form("sqlScript")("ContentType") = "text/plain" and objPGDUpload.form("sqlScript")("FileExt") = "sql" then body = objPGDUpload.form("sqlScript")("Binary") else err.raise 8888, "PGDUpload.GetForm", "The file you tried to upload was not a valid .sql file." body = empty end if else body = objPGDUpload.form("body")("Value") end if body = vbcrlf&vbcrlf&trim(replace(body&"",vbcrlf,vbcrlf&vbcrlf))&vbcrlf&vbcrlf if err.number<>0 and loadType="script" then response.write ("Error: Exception Occurred
Description: The data being processed is over the allowed limit. Please use the ""Load From File"" option below.

") elseif err.number<>0 and loadType<>"script" then response.write ("Error: "&err.source&"
Description: "&err.description&"

") else Dim regExpress Set regExpress = New regexp regExpress.global = true regExpress.ignorecase = true regExpress.multiline = true regExpress.pattern = "\r\n\s*?go\s*?\r\n" body = regExpress.replace(body,vbcrlf&vbcrlf&"GO"&vbcrlf&vbcrlf) Set regExpress = nothing Dim arrBody, i , ub arrBody = split(body,vbcrlf&"GO"&vbcrlf) ub = ubound(arrBody) 'response.write ub 'on error resume next call beginProcess() Dim returnRecord:returnRecord = iff(objPGDUpload.form("recordset")("Value")&""="on",true,false) SET objCon = server.createObject("ADODB.connection") with objCon .open datastore for i = 0 to ub err.clear if len(removeVBCRLF(arrBody(i)))<>0 then Dim strExecute:strExecute = trim(arrBody(i)) if returnRecord then Set objRS = .execute (strExecute) else .execute strExecute, , adExecuteNoRecords + adCmdtext end if if err.number <> 0 then response.write(""&(i+1)&"
") response.write (""&iff(syntax = "on","Test/Preview ","")&"Error: "&err.source&"
Description: "&err.description&"

") errored = true 'response.write "this" exit for else if reportq = "on" then response.write(""&(i+1)&"
") if syntax = "on" then response.write("Test/Preview passed!

") else response.write("Successfully executed!

") end if end if Dim strTextToWrite,objField, allData, iRow,iCol If returnRecord then Do Until objRS Is Nothing If objRS.State = adStateOpen Then Response.Write ("" & vbCrLf) Response.Write ("") For Each objField in objRS.fields Response.Write ("") Next Response.Write("" & vbCrLf) if not (objRS.EOF or objRS.BOF) then allData = objRS.GetRows if isArray(allData) then for iRow = 0 to ubound(allData,2) step 1 Response.Write ("") for iCol = 0 to ubound(allData,1) Dim rowContent:rowContent = iff(objPGDUpload.form("allowHTML")("Value")&""="on",""&allData(iCol,iRow),HTMLEncode(""&allData(iCol,iRow))) Response.write ("") next Response.Write ("") next allData = "" end if Response.Write ("
   " & iff(len(objField.name)=0,"(No column name)",objField.name) & "
" & vbCrLf) Response.Write ("

" & vbCrLf) End If Set objRS = objRS.NextRecordset Loop Set objRS = nothing End if if returnRecord or reportq="on" then response.write ("

") CAll outputProcess((1/ub)*100,"") end if end if next .close end with Set objCon = nothing if not errored then call finishedProcess () objectContext.SetComplete if deleteoption="deleteandrun" then Dim objFSO set objFSO = Server.CreateObject("Scripting.FileSystemObject") with objFSO if .fileexists(serverPath()&hostfile) then .DeleteFile serverPath()&hostfile, true end with set objFSO = nothing end if elseif errored and failsafe = "on" then objectContext.SetAbort else objectContext.SetComplete end if end if if syntax="on" then objectContext.SetAbort 'response.write "hollla" end if end if end if %>
" method="post" enctype="multipart/form-data" <%= iff( postBack and validData,"onsubmit=""return transac('"&exeWarning&"')""","") %>> <% if not (postBack and validData) then %> <% if not validData then response.write ("Login failed OR Database does not exist.

") session.contents.removeall end if %>
Database Name:
Server IP and Port:

Use Integrated Security *

* only database name and server IP are required.
<% else %> <% Dim dataString if sspi = "on" then dataString = datastoreTmp(0) else dataString = datastoreTmp(1) end if dataString = replace(dataString,"#dbServer#","") dataString = replace(dataString,"#dbName#","") dataString = replace(dataString,"#dbUser#","") dataString = replace(dataString,"#dbPass#","") response.write (dataString) %>

> Copy and Paste SQL Statements below:
<% session.contents.remove("body") %>

>Load From File (local):

> Verbose Mode (could be slow)
> Debug Mode (show the value of each form element)
onclick="syntaxChecking()"> Test/Preview Mode (does not actually execute the statements; combine "Return Recordset" option to preview)
> Fail-safe Mode (roll-back if any statement errors)
> Return Recordset   ( > Allow HTML in Recordset )

Script time out in seconds

"> <% end if %>

<% Set objPGDUpload = nothing %>