Click here to Skip to main content
15,887,364 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
Button Code:

Private Sub cmdnew_Click()
no
clear
Dim rs As New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
rs.Open "tbltrans", con, adOpenDynamic, adLockPessimistic 'This is the line where I get the error.

rs.AddNew

rs!transid = txttransid.Text

rs.Update
lbltotal.Caption = 0
txtitemcode.SetFocus
txtpaid.Text = ""
txtchange.Text = ""
cmdadd.Enabled = True
cmdnew.Enabled = False
cmddelete.Enabled = True
cmdedit.Enabled = True
cmdcompute.Enabled = True
End Sub

Module Code: 

Global con As New ADODB.Connection
Sub main()
On Error GoTo err
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\pos.mdb;Persist Security Info=False;Jet OLEDB:Database"
frmmain.Show
Exit Sub
err:
MsgBox ("Could not find database")
End Sub


What I have tried:

When I removed the frmLogin , frmSplash and frmMenu the error is gone and I can successfully start a new transaction.
Posted
Updated 10-Oct-16 6:08am
Comments
[no name] 10-Oct-16 11:40am    
Fix your connection string.
ZurdoDev 10-Oct-16 11:40am    
There should be an error message along with that error number. What is the full error?
F-ES Sitecore 10-Oct-16 11:50am    
"The connection cannot be used to perform this operation. It is either closed or invalid in this context."
ZurdoDev 10-Oct-16 11:53am    
That was one of the options I saw from google.

In this case, it seems pretty clear. con is not ready to go.

1 solution

If you don't understand an error message, google it: run - time 3709 vb6 - Google Search[^] and following any of the links will complete the message and probably explain what it means:
VB6 run-time error 3709 the connection cannot be used to perform the operation-it is either closed or invalid

So look at your connection using the debugger and find out exactly what teh connection command works out as.
Then check the file exists in that folder (and it shouldn't be there, that will fail in production even if you get it working in development as the Program Files folder is write protected).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900