Using an asp page to return a sql query

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Using an asp page to return a sql query

    I know that there must be a way to do this, but in my limited
    knowledge I am stuck.

    I am using 2 tables
    1. "BTstatus"
    BugIndex
    Date Entered
    Company
    Technician
    Developer
    PROGRAM
    Status
    PRIORITY

    2."noc"
    Bugindex
    # of calls
    Description

    Bug index is the common key

    I would like to display the first table and when you click on the
    Bugindex it would display like a select * from noc where bugindex ='?'
    ?= the bugindex #

    To go along with this on the new screen I would like to be able to
    update the # of calls for that particular bugindex. There are a ton of
    things out that that are sorta like this but nothing specifically.

    Thank you
    the chad Guest

  2. Similar Questions and Discussions

    1. I want to return an array instead of a query
      Dear Forum, My Flash program uses a web service connector that connects to a CFC. Everything works well with "return type="query. Now, I would...
    2. SQL Query not return date if we use <> operators
      Hi, I am in a way at this moment where I have to find records from tables where date are the primary field to be validated. In another word, I...
    3. Query return code question
      All... I'm having problems figuring out what pg_query() really returns when there is an error. The documentation says it returns "FALSE",...
    4. query to return table structure
      hi, Is there any command or query that returns the table structure informix.
    5. Prevent 'Page has expired' when a client hits back to return to a search page
      I have a search page that I want to enable private caching so that when a user hits the back button they dont get the page has expired error. I...
  3. #2

    Default Re: Using an asp page to return a sql query

    OK I am assuming you know how to connect to your database and retrieve recordsets for the 2 tables you have mentioned.

    Lets the connection object is objConn, the recordsets rsBTStatus and rsNOC.

    Your main asp page should have the following code:

    <%
    :
    :
    <Database connection code>
    :
    %>
    <Table width="100%">
    <TR>
    <TH>BugIndex</TH>
    <TH>Date Entered</TH>
    <TH>Company</TH>
    <TH>Technician</TH>
    <TH>Developer</TH>
    <TH>PROGRAM</TH>
    <TH>Status</TH>
    <TH>PRIORITY</TH>
    </TR>
    <%
    While not rsBTStatus.EOF
    %>
    <TR>
    <TD>
    <A HREF='NOC.ASP?Bindex=<%=rsBTStatus.Fields(0)%>'><% =rsBTStatus.Fields(0)%></A>
    </TD>
    <TD><%=rsBTStatus.Fields(1)%></TD>
    <TD><%=rsBTStatus.Fields(2)%></TD>
    <TD><%=rsBTStatus.Fields(3)%></TD>
    <TD><%=rsBTStatus.Fields(4)%></TD>
    <TD><%=rsBTStatus.Fields(5)%></TD>
    <TD><%=rsBTStatus.Fields(6)%></TD>
    <TD><%=rsBTStatus.Fields(7)%></TD>
    </TR>
    <%
    rsBTStatus.MoveNext()
    Wend
    %>
    :
    :
    <Close recrordsets and connection>



    Now your NOC.asp page should contain the following code:

    <%
    :
    :
    Dim strBugIndex
    Dim strSql

    strBugIndex = trim(Request.QueryString("Bindex"))
    :
    <Database connection code>
    :
    strSql = "Select * from NOC where BugIndex= ' " & strBugIndex & " '
    (Note: Theres no space between the single and double quotes)

    rsNOC.Open strSql, objConn
    %>
    <Table width="100%">
    <TR>
    <TH>BugIndex</TH>
    <TH># of calls</TH>
    <TH>Description</TH>
    </TR>
    <%
    While not rsNOC.EOF
    %>
    <TR>
    <TD><%=rsNOC.Fields(1)%></TD>
    <TD><%=rsNOC.Fields(2)%></TD>
    <TD><%=rsNOC.Fields(3)%></TD>
    </TR>
    <%
    rsNOC.MoveNext()
    Wend
    %>
    :
    :
    <Close recrordsets and connection>


    Havent tested the above code .. but hope you got the idea now .. clicking on the BugIndex link on the first page will open a new window with the NOC table listing records having the BugIndex that you clicked.

    HTH

    SPA


    "the chad" <cswartz@stromberg.com> wrote in message news:d5957558.0307310905.3c7734b3@posting.google.c om...
    > I know that there must be a way to do this, but in my limited
    > knowledge I am stuck.
    >
    > I am using 2 tables
    > 1. "BTstatus"
    > BugIndex
    > Date Entered
    > Company
    > Technician
    > Developer
    > PROGRAM
    > Status
    > PRIORITY
    >
    > 2."noc"
    > Bugindex
    > # of calls
    > Description
    >
    > Bug index is the common key
    >
    > I would like to display the first table and when you click on the
    > Bugindex it would display like a select * from noc where bugindex ='?'
    > ?= the bugindex #
    >
    > To go along with this on the new screen I would like to be able to
    > update the # of calls for that particular bugindex. There are a ton of
    > things out that that are sorta like this but nothing specifically.
    >
    > Thank you
    SPA Guest

  4. #3

    Default Re: Using an asp page to return a sql query


    I am assuming this would be an acceptable connection statement?
    <%

    Dim conn

    Set conn = Server.CreateObject("ADODB.Connection")

    conn.Open "Provider=SQLOLEDB; Data Source = (local); Initial Catalog =
    techsupportBT; User Id = sa; Password="

    If conn.errors.count = 0 Then

    Response.Write "Connected OK"

    End If

    %>
    IIS and SQL are on the same box


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    The Chad Guest

  5. #4

    Default Re: Using an asp page to return a sql query

    The Chad wrote:
    > I am assuming this would be an acceptable connection statement?
    > <%
    >
    > Dim conn
    >
    > Set conn = Server.CreateObject("ADODB.Connection")
    >
    > conn.Open "Provider=SQLOLEDB; Data Source = (local); Initial Catalog =
    > techsupportBT; User Id = sa; Password="
    >
    No, this is not acceptable: the sa account should never be used by an
    application (hopefully you don't really have a blank password for the sa
    account ... )

    Otherwise, it looks ok.

    Bob Barrows


    Bob Barrows Guest

  6. #5

    Default Re: Using an asp page to return a sql query



    I am just using it for an intranet web page as more of a managment tool,
    so I didn't figure security was that big of an issue for the situation.
    Thank you for all of your help.

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    The Chad Guest

  7. #6

    Default Re: Using an asp page to return a sql query

    The Chad wrote:
    > I am just using it for an intranet web page as more of a managment
    > tool, so I didn't figure security was that big of an issue for the
    > situation. Thank you for all of your help.
    >

    Many companies are hacked by their own employees. And Slammer worked partly
    because no passwords had been assigned to sa on the infected machines...

    But it's only a job ... you can always get another one ...

    Bob


    Bob Barrows Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139