Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Runtime error 3001 using ADO

Posted on 1998-12-15
13
Medium Priority
?
568 Views
Last Modified: 2013-12-25
I wrote an client application that uses ADODB to access a database on SQL-SERVER. For limiting the number of connections I wrote also an activex exe that will serve a adodb.connection object. This works! In my client I uses the folowing code to set the Connection object :

Dim Cn as new ADODB.Connection
Set Cn = MyObjStore.GetConnection

MyObjeStore is the ActiveX class I wrote and GetConnection is a property of that.
 Now when I try to open a resultset using the folowing code I receive an error :

Dim rstTemp as new ADODB.RecordSet
Rst.Open "SELECT * FROM orders",Cn

When I try this I receive the error : Runtime error 3001 The application is using arguments that are of the wrong type, are out of acceptable range, or are in conflict with one other.

But when I open the recordset using :

Dim RstTemp as ADODB.recordset
Set RstTemp = Cn.Execute ("SELECT * FROM orders")

This will work but it is much slower than the other! What am I doing wrong?????

Thanks in advance,

Evert Dieperink
0
Comment
Question by:evertd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
13 Comments
 
LVL 1

Expert Comment

by:chualk
ID: 1498273
Can u show how's your MyObjeStore code goes.
0
 
LVL 2

Author Comment

by:evertd
ID: 1498274
Yes, no problem :

Here is the class :

Public Property Get GetConnection() As ADODB.Connection
    Set GetConnection = Cn
End Property
Private Sub Class_Initialize()
    If Cn Is Nothing Then
        Set Cn = New ADODB.Connection
        Cn.Open ("uid=sa;pwd=;server\\gigant_sql\pipe\sql\query;driver={SQL Server};database=ted3;DSN='';")
    End If
End Sub

Here is the module :

Public Cn As ADODB.Connection

That was all!!! But like I said I can use the connection object! But not for creating resultsets!!


0
 
LVL 2

Author Comment

by:evertd
ID: 1498275
Adjusted points to 200
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 2

Author Comment

by:evertd
ID: 1498276
Adjusted points to 250
0
 
LVL 4

Expert Comment

by:tomook
ID: 1498277
Just to humor me, try
Rst.Open ("SELECT * FROM orders",Cn)
or
Rst.Open "SELECT * FROM orders", Cn, adOpenStatic, adLockOptimistic


0
 
LVL 5

Accepted Solution

by:
AnswerTheMan earned 500 total points
ID: 1498278
rsTemp.ActiveConnection=CN
rsTemp.Open(SQL STRING)
0
 
LVL 2

Author Comment

by:evertd
ID: 1498279
I tried that but that doesn't work!!! I will still get the same error! Byt the way that is not an answer it is a comment!! HUHU
0
 
LVL 4

Expert Comment

by:tomook
ID: 1498280
>>rsTemp.ActiveConnection=CN  
should be
Set rsTemp.ActiveConnection=CN  

btw, I don't post something as an answer unless I know it is correct.

0
 
LVL 2

Author Comment

by:evertd
ID: 1498281
I tried that already! But it doesn't work! I will still get error 3001 : the application is using arguments that are of the wrong type, are out of acceptable raange, or are in conflict with one another.

This is really strange because the connection object is good! When I try to execute a query using Cn.Execute is works and when I try to open a recordset using set rsttemp = cn.execute "blabla" is also works but the open method of an recordset object won't work!!!
0
 
LVL 4

Expert Comment

by:tomook
ID: 1498282
Has the recordset previously been used for something else? Perhaps there is an initialization problem. Could you show us the complete code where you open the recordset?
0
 
LVL 2

Author Comment

by:evertd
ID: 1498283
NO, I am sure there is nothing wrong opening the recordset.

If I try  :

Dim rstTemp as new ADODB.recordset
rsttemp.activeconnection = cn
rsttemp.open "SELECT * FROM orders"

I get the famous error!!! When I set the Cn object in my program instead of the activex exe I don't get the error!!!!
0
 
LVL 4

Expert Comment

by:tomook
ID: 1498284
Sounds suspiciously like a marshalling problem. Your connection is an out-of-process component, and perhaps your in-process recordset does not like using an OOP connection. The connection seems to have no problem creating a recordset, though. Unless anyone has any other ideas, this might be a Microsoft bug.
0
 
LVL 2

Author Comment

by:evertd
ID: 1498285
Huhu cool!! But how can I limit my connection using ADO in Visual Basic 6 ent edition without using MS-Transaction Server???
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question