View Full Version : needing a file defind

02-12-2003, 12:22 PM
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
<title>SQL Query tool</title>
TD {font-size: smaller }
<body bgcolor="#cecece">

<form name="queryform" action="query.asp" method="post">
<table border=0 cellspacing=0>
<b>SQL Code</b>

<textarea name="sql" rows="8" cols="50" wrap=soft><%=sql%></textarea>

<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)

<!-- this code allows you to test different connect strings -->
<td colspan=2>
<textarea name="dsn" rows="2" cols="80" wrap=soft><%=dsn%></textarea>
</tr> -->


<input type=submit>

'for long winded queries, this will write out the response buffers

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>")


'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>")
End If


'DML was performed
Response.Write("<tr bgcolor=White><td><b>")
Response.Write("Command Completed Successfully</b>")
end if

end if

'database clean up code
Set RS = Nothing

Thanks :)


02-12-2003, 02:05 PM
doesn't the title explain enough? :p

its a tool for executing a query entered by the user in a textfield, on a database selected by the user from a drop-down.

Probably for webbased databasemanagement

02-12-2003, 02:17 PM
Ok ok! What can I say its late and I am tired lol I think 6am should tell me time to goto bed lol I just had to figure out what to put into the box field now that I have I understand it better

Thankyou for your help though :)


02-13-2003, 02:18 AM
It's obvious you downloaded "register.zip" from my website! I'm glad that the other files made sense to you, I tried to keep them clean and simple for that purpose.

However, I also provided a link to the tutorial that provided that script (to me) in the first place, in the file "register.asp". It's here:


I also provided some sample queries in "register.asp" in the comments themselves.

If you go through that tutorial, and become familiar with SQL (Structured Query Language), you will find "query.asp" very VERY useful - knowing SQL (of course I also use SQL at work every day so I have an advantage), I can extract pretty much whatever information I want from my Access databases, and even update or delete information that was already entered!

Not to mention if you know SQL you become very sexy practically overnight. Besides, learning this stuff could perhaps get you a job or two. :D

02-13-2003, 06:09 AM
Whammy you are so full of great resources! Jobs in sql would be great specialy contract work! I seem to be understanding it better and better each day :) and as always I seem to be able to figure out problems I have about 3 mins after I post them to this site lol :)


02-14-2003, 01:30 AM
That's definitely a good sign... I know the feeling, oftentimes I will post a question, then work on it for a couple of minutes (after being frustrated for an hour beforehand) to just slap my forehead and say "duh!". Although more often than not I discover the answer IMMEDIATELY after I post. Haha. :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum