Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: rs.Update


Message #1 by bayou_ranch@m... on Sun, 26 May 2002 02:24:53
When I try to ad a new record to my data, it seems that if I try to 
update more than the number of fields below I get an error. here is the 
code snip

Dim iRecordAdded
 Dim DB_CONNSTRING
	DB_CONNSTRING = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & 
Server.Mappath("data/import_data.mdb") & ";"

set rs = Server.CreateObject("ADODB.Recordset")
  rs.Open "SELECT * FROM new_orders" , DB_CONNSTRING, adOpenKeyset, 
adLockPessimistic, adCmdText 

rs.AddNew

	rs.Fields("Timestamp") = Now()
	rs.Fields("FirstName") = Request.Form("FirstName")
	rs.Fields("LastName") = Request.Form("LastName")
	rs.Fields("web_site") = Request.Form("web_site")
	rs.Fields("consultation_fee") = Request.Form("consultation_fee")
	rs.Fields("item_order") = Request.Form("item_order")
	rs.Fields("Shipping_Method") = Request.Form("Shipping_Method")
	rs.Fields("item_name") = Request.Form("item_name")
	rs.Fields("StreetAddress") = Request.Form("StreetAddress")
	
	
	rs.Update

iRecordAdded = rs.Fields("id").Value


if I add even one more line to the rs.Fields portion I get this message:

Microsoft OLE DB Provider for ODBC Drivers error '80004005' 

[Microsoft][ODBC Microsoft Access Driver]Error in row 

confirmation.asp, line 33 


is there a way to update more fields?  I admit I am a total rookie.

Thanks in advance for the help.

William
Message #2 by "Ken Schaefer" <ken@a...> on Mon, 27 May 2002 12:12:17 +1000
Can you post the extra line of code that you added that causes the error?

<rant>
You post code that works, but don't post the code that generates the error.
Obviously the problem lies in the code that is causing the error - why don't
you post that to the list?!?
</rant>

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <bayou_ranch@m...>
Subject: [access_asp] rs.Update


: When I try to ad a new record to my data, it seems that if I try to
: update more than the number of fields below I get an error. here is the
: code snip
:
: Dim iRecordAdded
:  Dim DB_CONNSTRING
: DB_CONNSTRING = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" &
: Server.Mappath("data/import_data.mdb") & ";"
:
: set rs = Server.CreateObject("ADODB.Recordset")
:   rs.Open "SELECT * FROM new_orders" , DB_CONNSTRING, adOpenKeyset,
: adLockPessimistic, adCmdText
:
: rs.AddNew
:
: rs.Fields("Timestamp") = Now()
: rs.Fields("FirstName") = Request.Form("FirstName")
: rs.Fields("LastName") = Request.Form("LastName")
: rs.Fields("web_site") = Request.Form("web_site")
: rs.Fields("consultation_fee") = Request.Form("consultation_fee")
: rs.Fields("item_order") = Request.Form("item_order")
: rs.Fields("Shipping_Method") = Request.Form("Shipping_Method")
: rs.Fields("item_name") = Request.Form("item_name")
: rs.Fields("StreetAddress") = Request.Form("StreetAddress")
:
:
: rs.Update
:
: iRecordAdded = rs.Fields("id").Value
:
:
: if I add even one more line to the rs.Fields portion I get this message:
:
: Microsoft OLE DB Provider for ODBC Drivers error '80004005'
:
: [Microsoft][ODBC Microsoft Access Driver]Error in row
:
: confirmation.asp, line 33
:
:
: is there a way to update more fields?  I admit I am a total rookie.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Message #3 by bayou_ranch@m... on Mon, 27 May 2002 07:34:50
The next line of code would be:

rs.Fields("Address2") = Request.Form("Address2")

most of the time this form field will be blank.

Thanks

William

 Can you post the extra line of code that you added that causes the error?

<rant>
You post code that works, but don't post the code that generates the 
error.
Obviously the problem lies in the code that is causing the error - why 
don't
you post that to the list?!?
</rant>

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <bayou_ranch@m...>
Subject: [access_asp] rs.Update


: When I try to ad a new record to my data, it seems that if I try to
: update more than the number of fields below I get an error. here is the
: code snip
:
: Dim iRecordAdded
:  Dim DB_CONNSTRING
: DB_CONNSTRING = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" &
: Server.Mappath("data/import_data.mdb") & ";"
:
: set rs = Server.CreateObject("ADODB.Recordset")
:   rs.Open "SELECT * FROM new_orders" , DB_CONNSTRING, adOpenKeyset,
: adLockPessimistic, adCmdText
:
: rs.AddNew
:
: rs.Fields("Timestamp") = Now()
: rs.Fields("FirstName") = Request.Form("FirstName")
: rs.Fields("LastName") = Request.Form("LastName")
: rs.Fields("web_site") = Request.Form("web_site")
: rs.Fields("consultation_fee") = Request.Form("consultation_fee")
: rs.Fields("item_order") = Request.Form("item_order")
: rs.Fields("Shipping_Method") = Request.Form("Shipping_Method")
: rs.Fields("item_name") = Request.Form("item_name")
: rs.Fields("StreetAddress") = Request.Form("StreetAddress")
:
:
: rs.Update
:
: iRecordAdded = rs.Fields("id").Value
:
:
: if I add even one more line to the rs.Fields portion I get this message:
:
: Microsoft OLE DB Provider for ODBC Drivers error '80004005'
:
: [Microsoft][ODBC Microsoft Access Driver]Error in row
:
: confirmation.asp, line 33
:
:
: is there a way to update more fields?  I admit I am a total rookie.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Message #4 by "Ken Schaefer" <ken@a...> on Mon, 27 May 2002 16:56:02 +1000
Looking through MSDN, it appears that this is a rather esoteric error that
is usually caused when ADO encounters an unexpected data type.

I have one question, plus a number of suggestions:
Q) Is Address2 a memo field?


Suggestions:
a) Use the Jet OLEDB Provider instead of the ODBC driver, and make sure you
have the latest version. You can download the latest driver from:
www.microsoft.com/data - first download MDAC v2.7, then download Jet Service
Pack 3
You can get the OLEDB connection string from:
www.able-consulting.com/ado_conn.htm

b) Run "Compact and Repair" on your database - you can do this from within
Access.

c) Instead of doing SELECT * to open the recordset, open the recordset using
the tablename:

objRS.open "new_orders", objConn, adOpenKeyset, adLockOptimistic, adCmdTable
objRS.AddNew
objRS.Fields("Field1").Value = ...
objRS.Fields("Field2").Value = ...
objRS.Update

Then, add the new field values in the *same* order that they are in the
table, ie add the first field, then the second field etc.

d) If (a) doesn't work, then go back to using an SQL statement, however, put
any memo fields at the end of the field list:

strSQL = _
    "SELECT field1, field2, field3, memofield1, memofield2, memofield3 " & _
    "FROM new_orders "

e) If none of that works, then use an SQL statement to insert the
information into the database (this is the prefered method of updating an
Access database because you can skip the entire recordset/cursor
requirement. Have a look at:
www.adopenstatic.com/experiments/fastestautonumber.asp to get the code you
need to get the new autonumber value.

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <bayou_ranch@m...>
To: "Access ASP" <access_asp@p...>
Sent: Monday, May 27, 2002 7:34 AM
Subject: [access_asp] Re: rs.Update


: The next line of code would be:
:
: rs.Fields("Address2") = Request.Form("Address2")
:
: most of the time this form field will be blank.
:
: Thanks
:
: William



  Return to Index