error during opening the connection to ado 
Author Message
 error during opening the connection to ado

hello i'm a newbie. i'm using vb6 and access2000. i'm having this
error:

run-time error "3001" Arguments are of the wrong type, are out of
acceptable range,or are in conflict with one another

when I click my Add button.

a brief info on my form:

4 buttons:
1. cmdBtn(0) "Add"
2. cmdBtn(1) "Update"
3. cmdBtn(2) "Delete"
4. cmdBtn(3) "Exit"

3 text input
1. txtDate "Date"
2. txtDesc "Purchase description"
3. txtAmount "Amount paid"

Database
table "expenses"
tBil of type AutoNumber
iDate of type Date
strDesc of type Memo
fAmount of type Number

My code:
Dim db As ADODB.Connection
Dim recA As ADODB.Recordset

Private Sub cmdBtn_Click(Index As Integer)
    Static iNumOfClicks As Integer
    iNumOfClicks = iNumOfClicks + 1

    Select Case Index
    Case 0
        MsgBox "Number of Clicks: " & _
        CStr(iNumOfClicks) & " on Button Add"

    'this statement produced error    
    db.Open "expenses", "", "", adLockOptimistic

    recA.Open _
     "SELECT * FROM expenses WHERE tBil= 0", _
     con, adOpenKeyset, adLockOptimistic

     ' Create a new blank record
    With recA
        .AddNew

          ' Set the fields to the user-entered values
          ' from the html form used to collect the data
          !iDate = Me.txtDate
          !strDesc = Me.txtDesc
          !fAmount = Me.txtAmount

        ' Save the new record to the database
        .Update
    End With

    MsgBox "New record has been added!", _
     vbInformation, "Add Customer Record"
    'Call cmdReset_Click

    recA.Close
    db.Close
    Set recA = Nothing
    Set db = Nothing

    Case 1
        MsgBox "Number of Clicks: " & CStr(iNumOfClicks) & " on Button
Update"
    Case 2
        MsgBox "Number of Clicks: " & CStr(iNumOfClicks) & " on Button
Delete"
    Case 3
        MsgBox "Number of Clicks: " & CStr(iNumOfClicks) & " on Button
Exit"
        End
    End Select

End Sub

Private Sub Form_Load()
    Set db = New ADODB.Connection
    Set recA = New ADODB.Recordset

End Sub



Fri, 08 Oct 2004 17:38:47 GMT  
 error during opening the connection to ado

Quote:

> hello i'm a newbie. i'm using vb6 and access2000. i'm having this
> error:

> run-time error "3001" Arguments are of the wrong type, are out of
> acceptable range,or are in conflict with one another

> when I click my Add button.

> a brief info on my form:

> 4 buttons:
> 1. cmdBtn(0) "Add"
> 2. cmdBtn(1) "Update"
> 3. cmdBtn(2) "Delete"
> 4. cmdBtn(3) "Exit"

> 3 text input
> 1. txtDate "Date"
> 2. txtDesc "Purchase description"
> 3. txtAmount "Amount paid"

> Database
> table "expenses"
> tBil of type AutoNumber
> iDate of type Date
> strDesc of type Memo
> fAmount of type Number

> My code:
> Dim db As ADODB.Connection
> Dim recA As ADODB.Recordset

> Private Sub cmdBtn_Click(Index As Integer)
>     Static iNumOfClicks As Integer
>     iNumOfClicks = iNumOfClicks + 1

>     Select Case Index
>     Case 0
>         MsgBox "Number of Clicks: " & _
>         CStr(iNumOfClicks) & " on Button Add"

>     'this statement produced error
>     db.Open "expenses", "", "", adLockOptimistic

>     recA.Open _
>      "SELECT * FROM expenses WHERE tBil= 0", _
>      con, adOpenKeyset, adLockOptimistic

 Notice the argument 'con' in recA.Open? That should be the adodb
connection name, db. First you open an adodb connection, and then you
use it to open recordsets. The syntax for opening the adodb connection
(db in your example) is

connection.Open ConnectionString, UserID, Password, Options

The ConnectionString is something like this:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\mydatabase.mdb"

You can omit the UserID, Password, and Options if you don't need them.

 You can find out what connection string to use in code by putting an
ado data control on your form, going to the properties window to the
property 'connection string' and clicking the build button. This will
invoke a wizard that will prompt you for database type and let you
select the database from your disk drive. Then you can just copy that
string to your code, and delete the ado datacontrol.

--
john



Fri, 08 Oct 2004 22:53:26 GMT  
 error during opening the connection to ado
The word "expenses" is not a valid connection string and
adLockOptimistic is not a valid value for the Options argument either.
Look up the Open method in the ADO help and you'll see what your
choices are for the Options argument. There's also a link to the topic
about connection strings.


Sat, 09 Oct 2004 00:23:41 GMT  
 error during opening the connection to ado

Quote:

> The word "expenses" is not a valid connection string and
> adLockOptimistic is not a valid value for the Options argument either.
> Look up the Open method in the ADO help and you'll see what your
> choices are for the Options argument. There's also a link to the topic
> about connection strings.

thanks a lot i finally got this error solved. i'm thinking of
transfering my data from the database to the excel worksheet. how can
this be done? please help. or you can recommend me some sites that
have good tutorial on this


Sun, 10 Oct 2004 09:52:37 GMT  
 error during opening the connection to ado

Quote:


> > The word "expenses" is not a valid connection string and
> > adLockOptimistic is not a valid value for the Options argument either.
> > Look up the Open method in the ADO help and you'll see what your
> > choices are for the Options argument. There's also a link to the topic
> > about connection strings.

> thanks a lot i finally got this error solved. i'm thinking of
> transfering my data from the database to the excel worksheet. how can
> this be done? please help. or you can recommend me some sites that
> have good tutorial on this

i want to enter next record, there is an error occur. the error is at the

recA.CursorType = adOpenKeyset

what is happening here



Tue, 26 Oct 2004 11:07:58 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Trouble with ADO Connection.Open() Error 3625 Item not found in collection

2. ADO error when re-entering on an open connection

3. Help: 429 Error when opening an ADO connection

4. Setting up an ADO connection during runtime

5. ADO connection timesout during execution

6. Connection not Open + Server has not yet been opened error messages

7. Connection Errors via ADO Connection Object

8. Error during opening project

9. How to keep a window open during an Error Handling

10. Server error during open project (web wizard)

11. Run-Time Error 75 during Open For Binary

12. VB6 ADO Error -2147467259 During RecordSource Assignment In DataGrid

 

 
Powered by phpBB® Forum Software