Crash1hd
02-12-2003, 11:22 AM
Ok can someone explain what this asp file is for! Its called Query.asp It was downloaded with a sample script for logins that I have I have figured out every other files except this one
also if someone can explain how I would use it maybe an example
<% Response.Buffer=True %>
<%
'database startup code
dim RS 'recordset object
dim sConnString 'added by me
Set RS = Server.CreateObject("ADODB.Recordset")
'data source strings for drop down list
dim dsnarray(1)
'be sure to only populate the array elements zero
'through the upper bound of the DSN array
sConnString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Mid(Server.MapPath("\"), 1, InStrRev(Server.MapPath("\"),"\")-1) & "\database\Login website users.mdb;" & _
"Persist Security Info=False;"
dsnarray(0) = sConnString
Set Conn = Nothing
'retrieve the form values
sql = Request.Form("sql") 'the SQL statement
dsn = Request.Form("dsn") 'the data source string
%>
<html>
<head>
<title>SQL Query tool</title>
<style>
TD {font-size: smaller }
</style>
</head>
<body bgcolor="#cecece">
<form name="queryform" action="query.asp" method="post">
<table border=0 cellspacing=0>
<tr>
<td>
<b>SQL Code</b>
</td>
</tr>
<tr>
<td>
<textarea name="sql" rows="8" cols="50" wrap=soft><%=sql%></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<!-- using the drop down list of connect string -->
<select name="dsn">
<% ' loop through the array of DSN's select the current one
for i = 0 to UBound(dsnarray)
Response.Write("<option>" & dsnarray(i) & "</option>" & vbCrLf)
next
%>
</select>
</td>
</tr>
<!-- this code allows you to test different connect strings -->
<!--
<tr>
<td colspan=2>
<textarea name="dsn" rows="2" cols="80" wrap=soft><%=dsn%></textarea>
</td>
</tr> -->
</table>
<input type=submit>
</form>
<%
'for long winded queries, this will write out the response buffers
Response.Flush
%>
<%
if sql <> "" then ' execute the SQL if it's not empty
RS.Open sql, dsn
Response.Write("<table border=1 cellspacing=0>")
if RS.State = 1 then 'if the recordset has rows
'show the column names
Response.Write("<tr bgcolor=LightSteelBlue>")
for each f in RS.Fields
Response.Write("<td><b>" & f.Name & "</b></td>")
next
Response.Write("</tr>")
'show the rows
do while not RS.EOF
Response.Write("<tr bgcolor=White>")
for each f in RS.Fields
If Not IsNull(f.Value) Then
Response.Write("<td>" & Replace(Server.HTMLEncode(f.Value),vbCrLf,"<br />") & "</td>")
Else
Response.Write("<td> </td>")
End If
next
Response.Write("</tr>")
RS.MoveNext
loop
else
'DML was performed
Response.Write("<tr bgcolor=White><td><b>")
Response.Write("Command Completed Successfully</b>")
Response.Write("</td></tr>")
end if
Response.Write("</table>")
end if
%>
<%
'database clean up code
Set RS = Nothing
%>
</body>
</html>
</XMP></BODY></HTML>
Thanks :)
Adam
also if someone can explain how I would use it maybe an example
<% Response.Buffer=True %>
<%
'database startup code
dim RS 'recordset object
dim sConnString 'added by me
Set RS = Server.CreateObject("ADODB.Recordset")
'data source strings for drop down list
dim dsnarray(1)
'be sure to only populate the array elements zero
'through the upper bound of the DSN array
sConnString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Mid(Server.MapPath("\"), 1, InStrRev(Server.MapPath("\"),"\")-1) & "\database\Login website users.mdb;" & _
"Persist Security Info=False;"
dsnarray(0) = sConnString
Set Conn = Nothing
'retrieve the form values
sql = Request.Form("sql") 'the SQL statement
dsn = Request.Form("dsn") 'the data source string
%>
<html>
<head>
<title>SQL Query tool</title>
<style>
TD {font-size: smaller }
</style>
</head>
<body bgcolor="#cecece">
<form name="queryform" action="query.asp" method="post">
<table border=0 cellspacing=0>
<tr>
<td>
<b>SQL Code</b>
</td>
</tr>
<tr>
<td>
<textarea name="sql" rows="8" cols="50" wrap=soft><%=sql%></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<!-- using the drop down list of connect string -->
<select name="dsn">
<% ' loop through the array of DSN's select the current one
for i = 0 to UBound(dsnarray)
Response.Write("<option>" & dsnarray(i) & "</option>" & vbCrLf)
next
%>
</select>
</td>
</tr>
<!-- this code allows you to test different connect strings -->
<!--
<tr>
<td colspan=2>
<textarea name="dsn" rows="2" cols="80" wrap=soft><%=dsn%></textarea>
</td>
</tr> -->
</table>
<input type=submit>
</form>
<%
'for long winded queries, this will write out the response buffers
Response.Flush
%>
<%
if sql <> "" then ' execute the SQL if it's not empty
RS.Open sql, dsn
Response.Write("<table border=1 cellspacing=0>")
if RS.State = 1 then 'if the recordset has rows
'show the column names
Response.Write("<tr bgcolor=LightSteelBlue>")
for each f in RS.Fields
Response.Write("<td><b>" & f.Name & "</b></td>")
next
Response.Write("</tr>")
'show the rows
do while not RS.EOF
Response.Write("<tr bgcolor=White>")
for each f in RS.Fields
If Not IsNull(f.Value) Then
Response.Write("<td>" & Replace(Server.HTMLEncode(f.Value),vbCrLf,"<br />") & "</td>")
Else
Response.Write("<td> </td>")
End If
next
Response.Write("</tr>")
RS.MoveNext
loop
else
'DML was performed
Response.Write("<tr bgcolor=White><td><b>")
Response.Write("Command Completed Successfully</b>")
Response.Write("</td></tr>")
end if
Response.Write("</table>")
end if
%>
<%
'database clean up code
Set RS = Nothing
%>
</body>
</html>
</XMP></BODY></HTML>
Thanks :)
Adam