Populating another database with records from an asp page.

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

  1. #1

    Default Populating another database with records from an asp page.

    Apologies for the length of this mail but code is included.

    Have a page that pulls data from one database & displays the results, using
    a loop to display each record on the page:

    The select Query:

    strSQLtickets = "SELECT
    CALL.CALLID,CALASGN.ID20OPERID,CALL.CALLDAT,CALL.N AME,CUSEMAIL.NOTETEXT,CALL
    ..FACLSRN,CALCDESC.NOTETEXT FROM CALL INNER JOIN CALCDESC ON CALL.CDESC =
    CALCDESC.NOTEKEY INNER JOIN CALASGN ON CALL.CALLID = CALASGN.ID20CALLID
    INNER JOIN CUSTMER ON CALL.CUSTID = CUSTMER.CUSTID INNER JOIN CUSEMAIL ON
    CUSTMER.EMAIL = CUSEMAIL.NOTEKEY WHERE ((CALL.STATUS) IN ('OPEN','PENDING'))
    AND ((CALASGN.ID20GRPID) = 'GLO_BM') ORDER BY CALL.CALLDAT DESC, CALL.CALLID
    DESC"

    The loop:

    <% do while not rstickets.EOF 'begin loop that runs while queries still
    return data
    %>

    <table width="100%" border="1" align="center" cellpadding=4 cellspacing=0
    bordercolor="#003366" bgcolor="#FFFF99">
    <tr bgcolor="#336699">
    <th><font color="#FFFFFF" size="2" face="Tahoma">Call ID</font></th>
    <th><font color="#FFFFFF" size="2"
    face="Tahoma">Application</font></th>
    <th><font color="#FFFFFF" size="2" face="Tahoma">Call Date</font></th>
    <th><font color="#FFFFFF" size="2" face="Tahoma">Customer</font></th>
    <th><font color="#FFFFFF" size="2" face="Tahoma">Email</font></th>
    <th><font color="#FFFFFF" size="2" face="Tahoma">GLOBM
    Issue</font></th>
    </tr>
    <tr valign="top" bgcolor="#FFFFFF">
    <td align="center"> <div align="center"><font face="Tahoma"
    color="#000000" size="2"><%=zero(rstickets.fields(0))%></font><font
    color="#000000"></a></font></div></td>
    <td align="center"> <div align="center"><font face="Tahoma"
    color="#000000" size="2"><%=rstickets.fields(1)%></font></div></td>
    <td align="center"> <div align="center"><font face="Tahoma"
    color="#000000" size="2"><%=dat(rstickets.fields(2))%></font></div></td>
    <td align="center"> <div align="center"><font face="Tahoma"
    color="#000000" size="2"><%=rstickets.fields(3)%></font></div></td>
    <td align="center"> <div align="center"><font face="Tahoma"
    color="#000000" size="2"><%=rstickets.fields(4)%></font></div></td>
    <td align="center"> <div align="center"><font face="Tahoma"
    color="#000000" size="2"><%=rstickets.fields(5)%></font></div></td>
    </tr>
    </table>

    I want to put a button next to each record that is displayed on the page,
    that when pressed would populate the data from that record to another
    database. I can get my head around the update page that I would use, but my
    question is, how can I get this button to ctreate a new record in the other
    database with just the information for that record. I had though of
    declaring some variables and giving them the value of each field, like:

    Dim CallDate
    CallDate = rstickets.fields(3)

    But surely this variable would contain the date for all the records
    returned, not just a specific one.

    Is there any way of doing this? Do I perhaps not use a loop and do it some
    other way? Any help appreciated.

    Thanks.


    Miguel Orrego Guest

  2. Similar Questions and Discussions

    1. Populating Drop Down Boxes from a database
      We moved our wesite from a Box running Coldfusion 4.0 to a box running Coldfusion MX. We populate some drop down boxes with information from a...
    2. Web Form Populating Database
      Publisher 2003. Web form set to save the data in a comma-delimeted text file on my web server. Form working well, I'm able to use the wizard in...
    3. populating text from database
      I am trying to populate multiple textboxes from an Access database. I am trying to write code to generate the appropriate number of textboxes...
    4. Populating three list boxes from the database
      Can anybody help? I need to have three list boxes automatically populating each other, (ie when region is selected from the first listbox, it will...
    5. populating radiobuttonlist from database programmatically
      I store radiobuttonlist values in the db using the string value of the radio button item value. (nvarchar) I am creating an edit functionality on...
  3. #2

    Default Re: Populating another database with records from an asp page.

    Please consider fomatting your SQL so it is easily read...

    SELECT
    column_1, column_2, ......
    FROM
    table_name
    WHERE
    condition
    ORDER BY
    column_name

    If you must use caps, keywords only.

    Bob Lehmann

    "Miguel Orrego" <miguel@stressedmonkey.net-nospam> wrote in message
    news:3f04429f$0$958$cc9e4d1f@news.dial.pipex.com.. .
    > Apologies for the length of this mail but code is included.
    >
    > Have a page that pulls data from one database & displays the results,
    using
    > a loop to display each record on the page:
    >
    > The select Query:
    >
    > strSQLtickets = "SELECT
    >
    CALL.CALLID,CALASGN.ID20OPERID,CALL.CALLDAT,CALL.N AME,CUSEMAIL.NOTETEXT,CALL
    > .FACLSRN,CALCDESC.NOTETEXT FROM CALL INNER JOIN CALCDESC ON CALL.CDESC =
    > CALCDESC.NOTEKEY INNER JOIN CALASGN ON CALL.CALLID = CALASGN.ID20CALLID
    > INNER JOIN CUSTMER ON CALL.CUSTID = CUSTMER.CUSTID INNER JOIN CUSEMAIL ON
    > CUSTMER.EMAIL = CUSEMAIL.NOTEKEY WHERE ((CALL.STATUS) IN
    ('OPEN','PENDING'))
    > AND ((CALASGN.ID20GRPID) = 'GLO_BM') ORDER BY CALL.CALLDAT DESC,
    CALL.CALLID
    > DESC"
    >
    > The loop:
    >
    > <% do while not rstickets.EOF 'begin loop that runs while queries
    still
    > return data
    > %>
    >
    > <table width="100%" border="1" align="center" cellpadding=4
    cellspacing=0
    > bordercolor="#003366" bgcolor="#FFFF99">
    > <tr bgcolor="#336699">
    > <th><font color="#FFFFFF" size="2" face="Tahoma">Call ID</font></th>
    > <th><font color="#FFFFFF" size="2"
    > face="Tahoma">Application</font></th>
    > <th><font color="#FFFFFF" size="2" face="Tahoma">Call
    Date</font></th>
    > <th><font color="#FFFFFF" size="2"
    face="Tahoma">Customer</font></th>
    > <th><font color="#FFFFFF" size="2" face="Tahoma">Email</font></th>
    > <th><font color="#FFFFFF" size="2" face="Tahoma">GLOBM
    > Issue</font></th>
    > </tr>
    > <tr valign="top" bgcolor="#FFFFFF">
    > <td align="center"> <div align="center"><font face="Tahoma"
    > color="#000000" size="2"><%=zero(rstickets.fields(0))%></font><font
    > color="#000000"></a></font></div></td>
    > <td align="center"> <div align="center"><font face="Tahoma"
    > color="#000000" size="2"><%=rstickets.fields(1)%></font></div></td>
    > <td align="center"> <div align="center"><font face="Tahoma"
    > color="#000000" size="2"><%=dat(rstickets.fields(2))%></font></div></td>
    > <td align="center"> <div align="center"><font face="Tahoma"
    > color="#000000" size="2"><%=rstickets.fields(3)%></font></div></td>
    > <td align="center"> <div align="center"><font face="Tahoma"
    > color="#000000" size="2"><%=rstickets.fields(4)%></font></div></td>
    > <td align="center"> <div align="center"><font face="Tahoma"
    > color="#000000" size="2"><%=rstickets.fields(5)%></font></div></td>
    > </tr>
    > </table>
    >
    > I want to put a button next to each record that is displayed on the page,
    > that when pressed would populate the data from that record to another
    > database. I can get my head around the update page that I would use, but
    my
    > question is, how can I get this button to ctreate a new record in the
    other
    > database with just the information for that record. I had though of
    > declaring some variables and giving them the value of each field, like:
    >
    > Dim CallDate
    > CallDate = rstickets.fields(3)
    >
    > But surely this variable would contain the date for all the records
    > returned, not just a specific one.
    >
    > Is there any way of doing this? Do I perhaps not use a loop and do it some
    > other way? Any help appreciated.
    >
    > Thanks.
    >
    >

    Bob Lehmann Guest

  4. #3

    Default Re: Populating another database with records from an asp page.

    On Thu, 3 Jul 2003 15:50:05 +0100, "Miguel Orrego"
    <miguel@stressedmonkey.net-nospam> wrote:
    >Apologies for the length of this mail but code is included.
    I cut the code because it's not relevant to my response here, which is
    general and not specific code.
    >I want to put a button next to each record that is displayed on the page,
    >that when pressed would populate the data from that record to another
    >database. I can get my head around the update page that I would use, but my
    >question is, how can I get this button to ctreate a new record in the other
    >database with just the information for that record. I had though of
    >declaring some variables and giving them the value of each field, like:
    >
    >Dim CallDate
    >CallDate = rstickets.fields(3)
    >
    >But surely this variable would contain the date for all the records
    >returned, not just a specific one.
    >
    >Is there any way of doing this? Do I perhaps not use a loop and do it some
    >other way? Any help appreciated.
    You need a key field to use for this (not sure from your query exactly
    what your database structure is, maybe CALLID is the right key). Then
    in your code you do something like:

    Response.Write rs.Fields("CALLID") & <A HREF='modify.asp?ID=" &
    rs.Fields("CALLID") & "'>Copy to new table</A>"

    That creates a display line with a link to the ASP page that does the
    INSERT or UPDATE into the new table.

    Your Modify.asp does something like:

    ID=request.querystring("ID")
    SQLstmt = "SELECT * FROM OldTable WHERE CALLID='" & ID & "'"

    That gets the single record from the old table, then do an INSERT or
    UPDATE or whatever to put it into the new table. You'll want to check
    to see if the record exists and UPDATE or if not INSERT of course.

    Jeff


    ===================================
    Jeff Cochran (IIS MVP)
    [email]jcochran.nospam@naplesgov.com[/email] - Munged of Course

    I don't get much time to respond to direct email,
    so posts here will have a better chance of getting
    an answer. Besides, everyone benefits here.

    Suggested resources:
    [url]http://www.iisfaq.com/[/url]
    [url]http://www.iisanswers.com/[/url]
    [url]http://www.iistoolshed.com/[/url]
    [url]http://securityadmin.info/[/url]
    [url]http://www.aspfaq.com/[/url]
    [url]http://support.microsoft.com/[/url]
    ====================================
    Jeff Cochran Guest

  5. #4

    Default Re: Populating another database with records from an asp page.

    Two options:

    Option 1.
    Format the HTML so that each record is contained in its own form with
    the appropriate form fields. (U'll probably want to have these form
    fields hidden to discourage the user from changing the values.) When the
    button is clicked, the form would be submitted to the *.asp page that
    would insert the records. (If you want to use an image to handle the
    submit try using this statement in the <img> tag:
    onClick=document.frmInformationRequest.submit();
    (May need quotes, I'm quite tired at the moment).

    Option 2.
    Create a form where all of the form fields are hidden and match
    one-for-one the fields of the record. Format each record so that each
    value exists in its own <td></td> cell in a table. Name each <td> tag
    appropriately with an index value:
    <td id=name_1>
    <td id=email_1>
    <td id=phone_1>
    <td id=name_2>
    <td id=email_2>
    <td id=phone_2>
    Name each button according to the record's index id=record_1. In the
    onClick event for the button call a function which loops through each
    <td> tag, grabs the value and updates the value of the hidden fields in
    the form. The function would accept a value that indicates which record
    to copy (ex: onClick=insertRecord(1);).

    Option 1 will be easier to implement, however Option 2 will be a little
    bit more fun. While Opt2 is a bit more complex conceptually, the actual
    function shouldn't be that difficult to write. The FOR loop in
    loadCalendar() function on this page

    [url]http://www.gatewayorlando.com/content/reservationrequest.asp[/url]

    does basically what I'm describing. The nested FOR loop and the multiple
    IF...THENs make it complex, but that's only because its manipulating a
    table with specific constraints (7 cells across, 5 rows down). The

    document.getElementById("td_w" + weekIndex + "d" + dayIndex).innerHTML =

    statement is the workhorse in the function.

    David

    Jeff Cochran wrote:
    > On Thu, 3 Jul 2003 15:50:05 +0100, "Miguel Orrego"
    > <miguel@stressedmonkey.net-nospam> wrote:
    >
    >
    >>Apologies for the length of this mail but code is included.
    >
    >
    > I cut the code because it's not relevant to my response here, which is
    > general and not specific code.
    >
    >
    >>I want to put a button next to each record that is displayed on the page,
    >>that when pressed would populate the data from that record to another
    >>database. I can get my head around the update page that I would use, but my
    >>question is, how can I get this button to ctreate a new record in the other
    >>database with just the information for that record. I had though of
    >>declaring some variables and giving them the value of each field, like:
    >>
    >>Dim CallDate
    >>CallDate = rstickets.fields(3)
    >>
    >>But surely this variable would contain the date for all the records
    >>returned, not just a specific one.
    >>
    >>Is there any way of doing this? Do I perhaps not use a loop and do it some
    >>other way? Any help appreciated.
    >
    >
    > You need a key field to use for this (not sure from your query exactly
    > what your database structure is, maybe CALLID is the right key). Then
    > in your code you do something like:
    >
    > Response.Write rs.Fields("CALLID") & <A HREF='modify.asp?ID=" &
    > rs.Fields("CALLID") & "'>Copy to new table</A>"
    >
    > That creates a display line with a link to the ASP page that does the
    > INSERT or UPDATE into the new table.
    >
    > Your Modify.asp does something like:
    >
    > ID=request.querystring("ID")
    > SQLstmt = "SELECT * FROM OldTable WHERE CALLID='" & ID & "'"
    >
    > That gets the single record from the old table, then do an INSERT or
    > UPDATE or whatever to put it into the new table. You'll want to check
    > to see if the record exists and UPDATE or if not INSERT of course.
    >
    > Jeff
    >
    >
    > ===================================
    > Jeff Cochran (IIS MVP)
    > [email]jcochran.nospam@naplesgov.com[/email] - Munged of Course
    >
    > I don't get much time to respond to direct email,
    > so posts here will have a better chance of getting
    > an answer. Besides, everyone benefits here.
    >
    > Suggested resources:
    > [url]http://www.iisfaq.com/[/url]
    > [url]http://www.iisanswers.com/[/url]
    > [url]http://www.iistoolshed.com/[/url]
    > [url]http://securityadmin.info/[/url]
    > [url]http://www.aspfaq.com/[/url]
    > [url]http://support.microsoft.com/[/url]
    > ====================================
    David C Holley 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