Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 16th, 2004, 09:39 AM
vickerst vickerst is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Tallahassee, FLorida
Posts: 7 vickerst User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation using adodb recordset addnew


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.

Reply With Quote
  #2  
Old December 16th, 2004, 11:36 AM
vickerst vickerst is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Tallahassee, FLorida
Posts: 7 vickerst User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile resolved the problem

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!!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > using adodb recordset addnew


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT