Data | Database Many people must have used Query Analyzer, the function of this tool how, I do not need to say, this time to introduce under the Web under the Query Analyzer, the interface as shown in Figure 1, using ASP to write.
(Figure 1)
The source program is as follows:
<%
Dim conn
Dim connstr
On Error Resume Next
If Request ("selectdb") = "mdb" Then
If Request ("dbname") <> "then
Connstr= "dbq=" +server.mappath (Request ("dbname") + ";D efaultdir=;D river={microsoft Access DRIVER (*.mdb)};"
Set Conn=server.createobject ("ADODB. CONNECTION ")
If Err.number<>0 Then
Err.Clear
Set conn=nothing
Response.Write Error: Database connection Error! "
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 Error: Database connection error!!! <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 & ";D ata source=" & Request ("Sqlip") ' Sql_server database
ConnStr = ConnStr & "; User id= "& Request (" Sqladmin ") ' Database server users
ConnStr = ConnStr & "; password= "& Request (" Sqlpass ") ' Login password
ConnStr = ConnStr & "; Initial catalog=" & Request ("SQLDB") ' Database name
Set Conn=server.createobject ("ADODB. CONNECTION ")
If Err.number<>0 Then
Err.Clear
Set conn=nothing
Response.Write Error: Database connection Error! "
Else
Conn.Open ConnStr
If Err Then
Set conn=nothing
Response.Write Error: Database connection error!!! <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: "Song Body", "Arial narrow", "Times New Roman"; FONT-SIZE:9PT}
P {font-family: "Song Body", "Arial narrow", "Times New Roman"; FONT-SIZE:9PT}
BR {font-family: "Song Body", "Arial narrow", "Times New Roman"; FONT-SIZE:9PT}
TD {font-family: "Song Body", "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 how to use SQL statement help: \ n";
smsg = smsg + "1. Choose a command in the selection box \ n ";
smsg = smsg + "2. Click the [Show] button \ n ";
smsg = smsg + "3. The SQL statement appears in the text box on the left.
smsg = smsg + "4. Modify this statement to fit your database structure \ n ";
smsg = smsg + "5. Query results based on statements or execute commands \ n \ nplease ";
alert (smsg); }
else if (x = = 1) {
smsg = "Select ColumnName1, columnname2\n";
smsg = smsg + "from tablename\n";
smsg = smsg + "WHERE columnName = ' = ' = ' = ' \ 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";
Document.main.sql.value = smsg;
}
else if (x = = 3) {
smsg = "UPDATE tablename\n";
smsg = smsg + "SET columnName = ' value ' \ n";
smsg = smsg + "WHERE columnName = ' = ' = ' = ' \ n";
Document.main.sql.value = smsg;
}
else if (x = = 4) {
smsg = "DELETE columnname\n";
smsg = smsg + "from tablename\n";
smsg = smsg + "WHERE columnName = ' = ' = ' = ' \ n";
Document.main.sql.value = smsg;
}
else if (x = = 5) {
smsg = "creat