Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error when saving to SQL database 1

Status
Not open for further replies.

northflacomps

IS-IT--Management
Mar 27, 2004
5
US
Why do I get this error??

ADODB.Recordset error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

/employees/timesheet/control.asp, line 8

Here's my code for line 8:

Code:
rs.open "SELECT * FROM Entries", conn, adOpenDynamic, adLockOptimistic

I have used this same code hundreds of times without ever having a problem. Can someone tell me what the problem is with this code?
 
Don't use a recordset object and your problem is solved forever. You can pretty much get away with only using the Connection object most of the time. You'll need to create an ADODB.RECORDSET object for paging (all I can think of off the top of my head) though.
<%
set conn=server.createobject("ADODB.CONNECTION")
strSql="SELECT * FROM Entries"
set rs=conn.execute(strSql)
'loop through your records
set rs=nothing
conn.close
set conn=nothing
%>
 
I put in this new code, but how do I insert new records now? if says "Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype" when I try and use "rs.AddNew
 
I have to use all that INSERT INTO Table crap don't I? I hate that method. i rather use rs(field#)="data".

Can someone give me the INSERT INTO Table code then? Not sre how it goes. I try staying away from it.
 
Strings need to be surrounded by quotes. Numbers don't. It's much easier if you assign your request.form collection to variables first.
Code:
strSql="INSERT INTO tbl_MyTable " _
& " (txtValue1, numValue1, txtValue2) " _
& "VALUES" _
& " ('" & myTxtVar1 & "'," & myNumVar1 & ",'" & myTxtVar2 & "')"
conn.execute(strSql)
This is more efficient than rs(field#)="data" and if you move to SQLServer you'll be writing Insert and Update statements anyway and executing the Stored Procedures they're contained in. Might as well get used to it.
 
Instead of using constants who you couldnt have initialized you could use numbers
Code:
rs.open "SELECT * FROM Entries", conn, 3, 3 
is the way that works for me(all RS features enabled).

________
George, M
Searches(faq333-4906),Carts(faq333-4911)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top