I have a problem. When I run this code in asp the data I am saving into the table named Recipient gets duplicated but not always. It seems to work fine when I create a nwe record the first time but when I go to create more records it doubles up on the entries.
Anybody else have this problem before with MsAccess 2000?
My tables are relationally joined with the senderAID field joined with the RecipientID to be able to look up how many people the sender has emailed.
Code:<!-- #INCLUDE FILE="validate.asp" --> <!-- #INCLUDE FILE="data.asp" --> <% on error resume next Dim strAns strAns = "Please enter a valid e-mail" If Request.Form("Y1") = "" Then Session("Y1") = strAns Response.Redirect "EmailFriend.asp" End If Dim MyEmail(5) Dim frmEmail(5) Dim SenderEmail Dim chkOK Dim Count, frmCount Dim AllOK, objCDO, objCDO2, txtSubject, txtSubject2 SenderEmail = Request.form("Y1") MyEmail(0) = Request.form("A1") MyEmail(1) = Request.form("A2") MyEmail(2) = Request.form("A3") MyEmail(3) = Request.form("A4") MyEmail(4) = Request.form("A5") MyEmail(5) = Request.form("A6") chkOK = Request.form("C1") strOrigin = Request.ServerVariables("HTTP_REFERER") For Count = 0 to 5 If chkEmail(MyEmail(Count)) = 1 Then AllOK = AllOK + 1 End If Next If chkEmail(SenderEmail) = 1 Then AllOK = 1 End If If AllOk = 1 Then Response.Redirect "error.asp" End If If chkOK <> "" Then chkOK = True Else chkOK = False End If '--get email addresses SenderEmail = Request.form("Y1") frmEmail(0) = Request.form("A1") frmEmail(1) = Request.form("A2") frmEmail(2) = Request.form("A3") frmEmail(3) = Request.form("A4") frmEmail(4) = Request.form("A5") frmEmail(5) = Request.form("A6") '--Enter emails in DB Dim Dconn, sSQL, sSQL2, cmDC, SQL, SQL2, Recordset, AID Set Dconn = Server.CreateObject("ADODB.Connection") Dconn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & _ databasepath & ";" Set cmdDC = Server.CreateObject("ADODB.Command") cmdDC.ActiveConnection = Dconn SQL = "Select Sender.Email, Sender.AID FROM Sender WHERE " & "Sender.Email ='" & SenderEmail & "'" cmdDC.CommandText = SQL Set RecordSet = Server.CreateObject("ADODB.Recordset") RecordSet.Open SQL, DConn If Recordset.EOF Then sSQL = "INSERT into Sender(Email, OK2Remind, Origin)VALUES('" & SenderEmail & "','" & chkOK & "','" & strOrigin & "')" Dconn.Execute sSQL End If AID = Recordset.fields("AID") For count = 0 to 5 if frmEmail(count) <> "" then sSQL2 = "INSERT into Recipient(Email, SenderID)VALUES('" & frmEmail(count) & "'," & Recordset.fields("AID") & ")" Dconn.Execute sSQL2 cmdDC.Close Response.Write "sSQL2 = " & sSQL2 & "<BR>" end if Next set cmdDC = nothing Recordset.close set Recordset = nothing Dconn.Close Set Dconn = Nothing![]()




Reply With Quote