borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Question about populating MSFlexGrid)Next Topic (Firebird for beginners) New Topic New Poll Post Reply
AndreaVB Forum : Database : rum time error 3704
Poster Message
sushilgyl
Level: Trainee

Registered: 17-11-2008
Posts: 2

Ads by Lake Quincy Media
icon rum time error 3704

Private Sub Command1_Click()

Dim conConnection As New ADODB.Connection
    Dim cmdCommand As New ADODB.Command
    Dim rstRecordSet As New ADODB.Recordset
        
    conConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
      App.Path & "" & "dbtransaction.mdb;Mode=Read|Write"

    conConnection.Open
    
    If conConnection.State = adStateOpen Then
    MsgBox "connection found"
    Else
    MsgBox "connection not found"
    End If
    
    'Add a new record
    
    rstRecordSet.Open "select * from transaction", conConnection
    
    With rstRecordSet
      .AddNew
      .Fields(0) = "New"
      .Fields(1) = "Record"
      .Update
    End With
    
    rstRecordSet.Close
    conConnection.Close
    
    Set conConnection = Nothing
    Set cmdCommand = Nothing
    Set rstRecordSet = Nothing
    
End Sub


i m getting run time error 3704. wats the solution of this

Ads by Lake Quincy Media
17-11-2008 at 06:32 AM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1664
icon Re: rum time error 3704

Knowing where the error is happening would be helpful -- although in your code I see you have a messagebox displayed if it's opened or closed, but you continue on doing things assuming it's open.



____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)

17-11-2008 at 08:08 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 606
icon Re: rum time error 3704

Hi,
The main problem lies within your Connection String.
App.Path returns the path to the directory in which your Project resides, but it does not include a backslash at the end so you need to insert this between the App.Path variable and the name of your database.
The ReadWrite mode should not have a vertical bar between the 2 words - this bar is placed when mixing 2 modes - such as "ReadWrite|Share Deny None"
You also add 2 quotes with nothing in them, so really they are not doing anything.
Amend your Connection String to:-
conConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
      App.Path & Chr(92) & "dbtransaction.mdb;Mode=Share Deny None;Persist Security Info=False"
In addition, you will still have problems manipulating the returned Recordset as you have not specified a Lock Type that will allow you to Add New Records, so I suggest you change the rst Open to:-
rstRecordSet.Open "select * from transaction", conConnection, adOpenDynamic, adLockPessimistic



____________________________
multi-tasking - the ability to hang more than one app. at the same time.

20-11-2008 at 05:00 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : rum time error 3704
Previous Topic (Question about populating MSFlexGrid)Next Topic (Firebird for beginners) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder