|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello I hope I am posting in the right area. I have created a form that calls an page on submission that does two thing post to a access 2000 db and sends an email. my problem is that my addnew does not always add a new record to the db. I do not get an error and when I review the records id (autonumber) feild I can see where there were records not inserted (id 86 88 but no 87 listed). all feilds in the db allow null values, and I have some db inserted but not all that I ahve entered. O' and the form is in another page and I have confirmed that it is passing the data to tis page. here is my code. <!--#include virtual = "/common/includes/adovbs.inc"--> <% dim strname, stremail, strcomments, strpagelocation, strone, strtwo, strthree, strfour, strfive, strsix, strseven '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''' 'set connection and record set to mail db to insert info from the form ' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''' strname = request.form("Name") stremail = request.form("email") strcomments = request.form("Comments") strpagelocation = request.form("PageLocation") strone = request.form("0") strtwo = request.form("1") strthree = request.form("2") strfour = request.form("3") strfive = request.form("4") strsix = request.form("5") strseven = request.form("6") Dim cnDB ' as ADODB.Connection Dim rsQuery ' as ADODB.Recordset Set cnDB = Server.CreateObject ("ADODB.Connection") cnDB.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" _ & "E:\www\Leon\common\comment\_db\Comments.mdb" ''''''''''''''''' 'open connection' ''''''''''''''''' cnDB.Open '''''''''''''''''''''''''' 'set select for recordset' '''''''''''''''''''''''''' Set rsQuery = Server.CreateObject("ADODB.Recordset") rsQuery.Open "Select * From mail", cnDB, adOpenKeyset, adLockOptimistic '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''' 'check for errors, ' 'open 2 connection and insert email ino into mail db ' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''' on error resume next if cnDB.errors.count > 0 then response.write rsQuery & "<BR>" response.write "ERRORS HAVE OCCURRED<BR><BR>" for each error in cnDB.errors response.write (Error.number & ":" & error.description & "<br>") next else ''''''''''''''''''''''''''''''''''''''''' ' set data to add new record to database' ''''''''''''''''''''''''''''''''''''''''' rsQuery.AddNew rsQuery("Sender_Name") = strname rsQuery("Sender_Email") = stremail rsQuery("Sender_Comments") = strcomments rsQuery("From_Url") = strpagelocation rsQuery("SendTo1") = strone rsQuery("SendTo2") = strtwo rsQuery("SendTo3") = strthree rsQuery("SendTo4") = strfour rsQuery("SendTo5") = strfive rsQuery("SendTo6") = strsix rsQuery("AltSendto") = strseven rsQuery("ADate") = Now rsQuery.Update rsQuery.Close cnDB.Close end if %> <html> <head> <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>send email</title> </head> <body> <!--<form method="" action="" name="send_email">--> <!-- <input type="hidden" name="resulturl" value="thanks.htm">--> <%response.write "<B>Thank You for testing me</b><br>" If request.form("0") <> "" Then 'response.write "<input type='hidden' name='sendto' value='" & request.form("0") & "'>" response.write request.form("0") & "<br>" If request.form("1") <> "" Then 'response.write "<input type='hidden' name='sendto' value='" & request.form("1") & "'>" response.write request.form("1") & "<br>" If request.form("2") <> "" Then 'response.write "<input type='hidden' name='sendto' value='" & request.form("2") & "'>" response.write request.form("2") & "<br>" If request.form("3") <> "" Then 'response.write "<input type='hidden' name='sendto' value='" & request.form("3") & "'>" response.write request.form("3") & "<br>" If request.form("4") <> "" Then 'response.write "<input type='hidden' name='sendto' value='" & request.form("4") & "'>" response.write request.form("4") & "<br>" else end if If request.form("5") <> "" Then 'response.write "<input type='hidden' name='sendto' value='" & request.form("5") & "'>" response.write request.form("5") & "<br>" else end if else end if else end if else end if end if %> <p> <% response.write request.form("PageLocation") %></p> <!--</form>--> </body> </html> can someone please help me. |
|
#2
|
|||
|
|||
|
post from another form - You have On Error Resume Next turned on, which is supressing any errors that are occuring, and the only error checking that you do happens *before* you try to call AddNew.
by commenting out the on error did give me the error, which I have fixed thanks so much. The problem was that one of the feild receives a url, and the url was larger than the feild. Thanks again this was driving me crazy!! |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > using adodb recordset addnew |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|