Could someone help me please....

Results 1 to 2 of 2

Thread: Could someone help me please....

  1. #1
    Join Date
    Dec 1969

    Default Could someone help me please....

    I have a problem.<BR><BR>Bascially I am pulling information from a SQL DB and am using <BR><BR>do until rs2.eof<BR>insert into *<BR>response.write " " &name &" "<BR>response.write " " &email &" "<BR>rs2.movenext<BR>loop<BR><BR>this works fine as is inserting the correct records i need into a database and displaying them as well on the page correctly, the problem is it keeps inserting new rows everytime you visit that page, how can I get it to only insert once??? is this possible?? I still want it to do the showing records bit, just not insert if already exsists...thanks alot.

  2. #2
    Join Date
    Dec 1969

    Default How do rs2 ..

    ... and the insert statement relate to each other?<BR><BR>ie. what are your table names? And what fields are in each?<BR><BR>Basically, I&#039;d get a recordset for rs2 that contains all of the records and gives you an indication if the record needs to be inserted into the other table or not.<BR><BR>You can do that with an outer join. An example for SQL Server would be something like:<BR>[code language="T-SQL"]<BR>SELECT t1.ID,<BR> t1.NAME,<BR> t1.EMAIL,<BR> ISNULL(t2.ID, -1) AS NeedInsert<BR>FROM Table1 AS t1<BR> LEFT OUTER JOIN Table2 AS t2 ON t1.ID = t2.ID<BR>[/code]<BR><BR>Then, your ASP code could check:<BR>[code language="VBScript"]<BR>If rs2("NeedInsert") = -1 Then<BR> &#039;do insert<BR>End If<BR><BR>&#039;do display<BR>[/code]

Posting Permissions

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