資料庫的Query Analyzer

來源:互聯網
上載者:User
資料|資料庫 很多人一定用過Query Analyzer,這個工具的功能如何如何,就不用我說了,這次給大家介紹下Web下的Query Analyzer,介面如圖1,使用ASP寫的。

(圖1)

來源程式如下:

<%
dim conn
dim connstr

on error resume next
if request("selectdb")="mdb" then
if request("dbname")<>"" then
connstr="DBQ="+server.mappath(request("dbname"))+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
if err.number<>0 then
err.clear
set conn=nothing
response.write "錯誤:資料庫連接出錯!"
else
if request("dbpass")<>"" then
conn.open connstr
else
Conn.Open connstr,"admin",request("dbpass")
end if
if err then
set conn=nothing
response.write "錯誤:資料庫連接出錯!!!<br>" + err.description
err.clear
end if
end if
end if
elseif request("selectdb")="mssql" then
if request("dbname")<>"" then
connstr = "Provider=SQLOLEDB.1"
connstr = connstr & ";Data Source=" & request("sqlip") 'sql_server資料庫
connstr = connstr & ";User ID=" & request("sqladmin") '資料庫伺服器使用者
connstr = connstr & ";Password=" & request("sqlpass") '登入口令
connstr = connstr & ";Initial Catalog=" & request("sqldb") '資料庫名
set conn=server.createobject("ADODB.CONNECTION")
if err.number<>0 then
err.clear
set conn=nothing
response.write "錯誤:資料庫連接出錯!"
else
conn.open connstr
if err then
set conn=nothing
response.write "錯誤:資料庫連接出錯!!!<br>" + err.description
err.clear
end if
end if
end if
end if
sub endConnection()
conn.close
set conn=nothing
end sub

%>
<HTML>
<HEAD>
<TITLE>Query Analyzer</TITLE>
<STYLE type=text/css>BODY {FONT-FAMILY: "宋體", "Arial Narrow", "Times New Roman"; FONT-SIZE: 9pt}
P {FONT-FAMILY: "宋體", "Arial Narrow", "Times New Roman"; FONT-SIZE: 9pt}
BR {FONT-FAMILY: "宋體", "Arial Narrow", "Times New Roman"; FONT-SIZE: 9pt}
TD {FONT-FAMILY: "宋體", "Arial Narrow", "Times New Roman"; FONT-SIZE: 9pt}
.p9 {FONT-SIZE: 9pt; LINE-HEIGHT: 14pt}
A:link {COLOR: #004080; FONT-SIZE: 9pt; LINE-HEIGHT: 14pt; TEXT-DECORATION: none}
A:visited {COLOR: #004080; FONT-SIZE: 9pt; LINE-HEIGHT: 14pt; TEXT-DECORATION: none}
A:hover {COLOR: #ff0000; FONT-SIZE: 9pt; LINE-HEIGHT: 14pt; TEXT-DECORATION: underline}
.p105 {FONT-SIZE: 10.5pt}
INPUT.yellowbtn {BACKGROUND-COLOR: #88a3f2; COLOR: #000000; FONT-SIZE: 9pt}
</STYLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" topmargin="0">
<script language=JavaScript>
function setWB(x) {
document.main.whichbutton.value = x;
document.main.submit();
}

function showSQL(x) {

sqlvalue = document.main.sql.value;

if (x == 0) {
smsg = "\n怎樣使用sql語句協助:\n\n";
smsg = smsg + "1. 在選擇框裡選一個命令\n";
smsg = smsg + "2. 點擊[顯示]按鈕\n";
smsg = smsg + "3. sql語句會顯示在左邊的文字框裡面\n\n";
smsg = smsg + "4. 修改此語句來適合你資料庫結構\n\n";
smsg = smsg + "5. 根據語句查詢結果或執行命令\n\n";
alert(smsg); }

else if (x == 1) {
smsg = "SELECT columnName1, columnName2\n";
smsg = smsg + " FROM tableName\n";
smsg = smsg + " WHERE columnName = 'value'\n\n";
document.main.sql.value = smsg;
}

else if (x == 2) {
smsg = "INSERT INTO tableName\n";
smsg = smsg + " (columnName, IntegerColumnName)\n";
smsg = smsg + " VALUES ('value', numericValue)\n\n";
document.main.sql.value = smsg;
}

else if (x == 3) {
smsg = "UPDATE tableName\n";
smsg = smsg + " SET columnName = 'value'\n";
smsg = smsg + " WHERE columnName = 'value'\n\n";
document.main.sql.value = smsg;
}

else if (x == 4) {
smsg = "DELETE columnName\n";
smsg = smsg + " FROM tableName\n";
smsg = smsg + " WHERE columnName = 'value'\n\n";
document.main.sql.value = smsg;
}

else if (x == 5) {
smsg = "CREAT



相關文章

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。