By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,773 Members | 2,583 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,773 IT Pros & Developers. It's quick & easy.

Addnew Method, ASP, MS-Access returns 500 error

P: n/a
I have been fighting with this script for several days and I'm finally
at the end of my rope. Here's the scenario:

-I have to add an entry into 1 table, called "calendar"
-I must retrieve the newly created autonumber field from this record
-Use the new ID number and insert it into a second table called
"cal_details"

--------------Begin Code--------------------
connString = "dsn=atpm"
set conn = Server.CreateObject("ADODB.connection")
conn.connectionTimeOut = 20
conn.open connString,"userName","password"

set rs = Server.CreateObject("ADODB.recordset")
rs.ActiveConnection = conn
rs.CursorLocation = adUseServer
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
rs.Source = "calendar"
rs.Open

rs.addNew
rs("calID") = Request("calendarID")
rs("subject") = Request("eventSubject")
rs.Update

eventId = rs("event_id")

If conn.Errors.Count > 0 Then
For Each Err In conn.Errors
Response.Write("Error " & Err.SQLState & ": " & _
Err.Description & " | " & Err.NativeError)
Next
conn.Errors.Clear
rs.cancelUpdate
End If
rs.close
set rs = nothing

'More code after this to add subsequent data to the cal_details table
---------End Code------------

Anyway, When I strip the code down and comment out the "rs.AddNew"
portion, there aren't any error. The moment I enable the code, I get a
500 server error (of course, it won't display the reason for the
error..I gotta work on better error handling).

Why doesn't the addNew method work? When I do a check on the recordset:

boolTest = rs.Supports(adAddNew)

It returns "true"

Is there a setting i'm missing, can someone tell me? I have tried
several of the samples/tutorials on 4guysfromrolla.com, aspfree.com and
msdn.microsoft.com and none of them seem to work. The moment I enable
that "addNew" method, the server craps out on me with the 500 error.

On a side note, I was successfully able to run the code on a MySQL
database without a hitch.

Please help?

TIA,

--
Jon Trelfa
There 10 kinds of people in this world...
Those who understand binary and those who don't

Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Jon Trelfa wrote:
I have been fighting with this script for several days and I'm finally
at the end of my rope. Here's the scenario:

-I have to add an entry into 1 table, called "calendar"
-I must retrieve the newly created autonumber field from this record
-Use the new ID number and insert it into a second table called
"cal_details"

<snip code>

Anyway, When I strip the code down and comment out the "rs.AddNew"
portion, there aren't any error. The moment I enable the code, I get
a 500 server error (of course, it won't display the reason for the
error..I gotta work on better error handling).

Why doesn't the addNew method work? When I do a check on the
recordset:

boolTest = rs.Supports(adAddNew)

It returns "true"

Is there a setting i'm missing, can someone tell me? I have tried
several of the samples/tutorials on 4guysfromrolla.com, aspfree.com
and msdn.microsoft.com and none of them seem to work. The moment I
enable that "addNew" method, the server craps out on me with the 500
error.

On a side note, I was successfully able to run the code on a MySQL
database without a hitch.

Please help?

TIA,


John,

I don't have an answer for your problem, but a few suggestions:

- if you're testing in IE, go to Tools-->Internet Options-->Advanced, and
uncheck the Show Friendly HTTP Error Messges box. That will often get you
much more specific error information.

- check out http://www.aspfaq.com/ . They have some very helpful ASP/Access
info. The article:

http://www.aspfaq.com/show.asp?id=2174

covers what you're trying to do.

--

Peter Palmieri
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.