Wrox Programmer Forums
|
VB Components Issues specific to components in VB.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Components section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 20th, 2004, 05:35 AM
Registered User
 
Join Date: Mar 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Arguments error


Hi all.

I have the folloving code in my VB project:

Function GetRecordset(ByVal sSQL As String, ByVal oDbConnection As ADODB.Connection) As ADODB.Recordset

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

'To use disconnected Recordset you must use client side cursors
rsObj.CursorLocation = adUseClient

rsObj.Open sSQL, oDbConnection

Set GetRecordset = rsObj

End Function

And I'm keeping to recieve the folloving error:

error '800a0bb9'

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

Error appears in the line with:

rsObj.Open sSQL, oDbConnection

GetRecordset function is called from GetData function, which is called from asp page.

Structure of GetData function goes like this:

Function GetData(ByVal oDbConnection As ADODB.Connection) As ADODB.Recordset

    Dim sSQL As String
    sSQL = "SELECT * FROM TABLE"

    Set GetData = GetRecordset(sSQL, oDbConnection)

End Function

Then GetData function is called from asp:

    Dim Conn
    Dim rsTest

    Set Conn = Getconn()
    Set rsTest = prjTest.GetData(Conn)

    ' .. manipulations

    Set Conn = Nothing
    Set rsTest = Nothing

I tried different variants of GetRecordset and GetData functions but error doesn't dissapear.
Btw when I lanch an asp page not in VB Debugger, everything works fine.


 
Old July 20th, 2004, 12:27 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

"SELECT * FROM TABLE" in GetData is missing the name of the table.
Marco
 
Old July 24th, 2004, 04:15 AM
Registered User
 
Join Date: Mar 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

With SQL everything is correct. This is just a sample.
The problem is somevere in Getrecordset or Getdata functions.
In the line with oDbConnection.

 
Old July 26th, 2004, 09:39 AM
Registered User
 
Join Date: Jan 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hai just check the things one more with Con.Execute pass the connection by ref and not by val, this is to optimize the code,
check for if the referecing to the Adodb is done or not.
Try all this out you may get what you want.

Regards
Vinay Bhushan.S
site://www28.brinkster.com/developerhome/

Vinay Bhushan.S
Zenith Software Ltd.

http://www28.brinkster.com/developerhome/
 
Old July 27th, 2004, 05:54 AM
Registered User
 
Join Date: Mar 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ByRef or Byval doen't help. I trued all variations.
I also tried to change Getrecordset function like this:

Function GetRecordset(ByVal sSQL As String, ByVal oDbConnection As ADODB.Connection) As ADODB.Recordset

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

Set oTempRS.ActiveConnection = oDbConnection

rsObj.CursorLocation = adUseClient
rsObj.CursorType = adOpenStatic
rsObj.LockType = adLockBatchOptimistic
rsObj.Source = sSQL
rsObj.Open

Set GetRecordset = rsObj

End Function

And I am still having same error in line with:

Set oTempRS.ActiveConnection = oDbConnection

BTW when I try oDbConnection.Execute(sSQL) it works fine.
The problem is that I need all those cursor and lock settings.


 
Old July 27th, 2004, 06:10 AM
Authorized User
 
Join Date: Jun 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Dhodie
Default

Hi Andris,

You have not declared the variable "oTempRS"
replace this by "rsObj" and it will work just fine. You may have just committed typo error here.

Good luck! Happy Programming!

-Dhodie

 
Old July 27th, 2004, 12:48 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The error you get (3001) is invalid argument, and it is (usually) thrown by an invalid SELECT clause. Check the synatx in your sSQL string, and see if it has anyhting invalid in it. You can also cut and paste it in a query analizer to see if it works.
If that is fine, which database are you using? Did you check if your cursors/lock types are supported?
Marco
 
Old July 29th, 2004, 04:36 AM
Registered User
 
Join Date: Mar 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi marcostraf,

I checked SQL. There are no mistakes.
Btw when I use following function:

Function GetRecordset(ByVal sSQL As String, ByVal oDbConnection As ADODB.Connection) As ADODB.Recordset

Set GetRecordset = oDbConnection.Execute(sSQL)

End Function

everytyhing works fine.

The problem is in the line with oDbConnection.

I tested function on MS SQL Server 2000 and MySQL 4: same error in both databases.


 
Old July 29th, 2004, 12:08 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Did you look into the knowlwdge base article Q193093:
FIX: Setting Rst.ActiveConnection to a Recordset Causes GPF

Marco
 
Old July 30th, 2004, 12:57 AM
Registered User
 
Join Date: Jan 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hai can you just make some good writing what is the sql statement which you are executing are the single quotes and all correct the one thing what you should not do is this

fnReturn = con.execute(Ssql) dont do this because if the result set is not comming then you will find problems returning

pass a obj by ref to the function assign it and get a boolean from the function like

public function fnReturn(byref objCon as object, byref objRs as object,byval Ssql as string)as boolean
dim ors as new adodb.recordset
set ors = objCon.execute(Ssql)

if Not ors then
   fnReturn=false
else
   fnReturn=true
end if
end function


Vinay Bhushan.S
Zenith Software Ltd.

http://www28.brinkster.com/developerhome/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Query w/ arguments darkhalf Access VBA 2 March 3rd, 2008 10:04 AM
arguments relay pierre.voisin Javascript 1 February 20th, 2008 06:04 PM
Named arguments Bob Bedell C# 2 March 19th, 2006 09:25 PM
Arguments snowy0 VB.NET 2002/2003 Basics 3 September 3rd, 2004 08:40 AM
Program arguments bramtram VB How-To 1 August 14th, 2003 03:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.