Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    51° 03' -78" N -114° 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    needing a file defind

    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>&nbsp;</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

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    doesn't the title explain enough?

    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
    I am the luckiest man in the world

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    51° 03' -78" N -114° 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

    Adam

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:

    http://hotwired.lycos.com/webmonkey/...tml?tw=backend

    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.
    Last edited by whammy; 02-13-2003 at 01:22 AM.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Location
    51° 03' -78" N -114° 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

    Adam

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •