Unspecified Error (problem)

jerome_gail26
10-11-2009, 08:00 PM
Hi,

VB6.0
MSACCESS (.mdb)

On first run i can save, edit. delete etc. in the application with no problem and both client/server are updated. But sometimes i got error UNSEPECIFIED ERROR message. And when i remove and highlights the connection.

Here are some code that I suspect the reason for the said error.


'MODULE
Public dbConnectMDB As New ADODB.Connection

Function ConnectNow()
Set dbConnectMDB = New Connection
dbConnectMDB.Open "PROVIDER=MSDataShape;Data PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & "Z:\MyDatabase.mdb"
End Sub



'FORM
Dim rs_Record as New ADODB.Recordset
Private Sub Command1_Click()
Call ConnectNow
Set rs_Record = New Recordset
rs_Record.Open "UPDATE Receive_Delivery SET Landed_Cost = '" & txt_Price.Text & "' " & _
" Where SKU_Number = '" & txt_Sku.Text & "'", db_rDel, adOpenDynamic, adLockOptimistic
Set Datagrid1.Datasource = rs_Record
End Sub


Hope you can help me here.

Thanks in advance,
Jerome And Gail

Roger_Wgnr
10-11-2009, 10:26 PM
Couple of things I noticed.
First you set the Connection to a new connection object twice.
I would change
Public dbConnectMDB As New ADODB.Connection
to
Public dbConnectMDB As ADODB.Connection
Then you also need to close the connection.
Nowhere in the code you posted did you close the connection.
I think the error may be caused by a connection already being open to the database.

You really should add a check for an exising connection.
Function ConnectNow()
If dbConnectMDB Is Nothing then
Set dbConnectMDB = New Connection
dbConnectMDB.Open "PROVIDER=MSDataShape;Data PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & "Z:\MyDatabase.mdb"
End If
End Sub

jerome_gail26
10-12-2009, 06:55 PM
Thanks

I will try it.

Sometimes the error does not show.

Thanks Again,
Jerome and Gail

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum