在线数据库管理工具(db007) v1.5

2019-01-14 08:01:18于丽

    sql = trim(request("sql"))
    if sql = "" then exit sub

    sql = RegExpReplace(sql, "(--)(.)*n", "")   '替换注释
    sql = RegExpReplace(sql, "n[s| ]*r", "")  '替换空行
    sql = RegExpReplace(sql, "n", "")           '替换换行符
    sql = RegExpReplace(sql, "r", "")           '替换回车符
    if (LCase(left(sql,len("select"))) = "select") and instr(sql,"into") = 0 then
       Call showSelect (sql)
       if err <> 0 then echo "<br><font color=red>" & err.description & "</font>"
       response.end
    else
           '如果非select语句,允许执行多条以分号分隔的语句
           dim aSql,iLoop
           aSql = split(sql,";")
           for iLoop = 0 to UBound(aSql)
            if trim(aSql(iLoop)) <> "" then
                  conn.execute (aSql(iLoop))
                if err <> 0 then
                    echo "<br><font color=red>" & err.description & "<br>  <b>"
                    echo iLoop + 1 & "、</b></font><font color=#CC6600>" & aSql(iLoop) & "</font><br>"
                    'err.clear()     '忽略错误
                    exit sub          '中止执行
                else
                    echo "<div style='padding:3px 0px;border-bottom:1px solid #069;'><b>" & iLoop + 1 & "、</b>" & aSql(iLoop) & "</div>"
                end if
            end if
        next
        echo "<font color=red><h4>命令执行成功</h4></font>"
   end if
end sub