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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arguments are of the wrong type...

Status
Not open for further replies.

robinsql

Programmer
Aug 2, 2002
236
0
0
IE
Hi all,

I'm in a serious spot of bother with this one.
Line 2 of the following code returns the error...

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

Line 3 runs fine.

Can anyone explain to me what the problem is? I need to resolve this one fairly urgently! I need to use the first method.

I'm using Active X Data Objects 2.5 library

1) sSQL = "Select * from tblDel Where Job ='" & strJobNo & "'"

2) oRs.Open sSQL, oConn, adOpenKeyset, adLockOptimistic

3) Set oRs = oConn.Execute(sSQL)


Thanks for any help,
Robin
 

Are you sure that no other properties of oRS are being set prior to openning it?

Did you create the oRS using the CreateObject method, and do not have a reference set to the ADO library?

What happens when you use:

oRs.Open sSQL, oConn, 1, 3
?
 
Dim oRs As Recordset
Set oRs = New Recordset

These are the only other references to the recordset object.
The code is in a DLL.
Proving to be a very frustrating one!
Thanks for the help
 
Try this and see if it works.

Dim oRs As ADODB.Recordset
Set oRs = New ADODB.Recordset

oRs.Open sSQL, oConn 'No further arguments




 

Is the connection object also created with-in the dll?

Does the same code work in the main program?

I really don't see what else could be causing it.
Normally, the error says that one of the arguments, such as LockType is the wrong value (i.e. = 0 would cause this error)

Or one or more of the variables/constants used (sSQL, oConn, adOpenKeyset, or adLockOptimistic), are not declared as the correct type:
Dim sSQL As String
Dim oConn As ADODB.Connection
adOpenKeyset = 1%
adLockOptimistic = 3%

Also make SURE you have
Option Explicit
at the top of the declarations section.

After changing the code as in my last post, does the oConn.Execute method still work?

I am off for the day. Hope it works out for you.
I will check tomorrow morning to see what you have found out.

 
Hey CClint,
Thanks for your help. Couldn't get back to you yesterday as we had an internet problem.
Unfortunately I have not found a reason for the error, so I have just decided to use oConn.execute instead. I don't suppose this will harm the program.
The reason I was reluctant to change it, is because this code is actually running on one of our client sites so must be working there. Although, it may not be as the project is very messy and has no documentation. Or error handling for that matter.
If you can think of any reason why this occurs, I'd love to hear it. The connection object is passed to teh dll and not created within.

Thanks very much,
Robin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top