|
-
ADO won't connect to DB
Hi all.
I have a rather interesting problem that I hope someone can help me with.
My program controlls a 6-axis CNC milling machine. Users send co-ordinates
into an Access 2000 database, my program reads the co-ordinates, and sends
the co-ordinates to the mill. At random, I cannot connect to the database.
I reuse the same function to get the next co-ordinate, so I know that the
function works. Once the function cannot connect to the database, all other
functions will not connect to the database. Below is the code clippit for
retrieving the next X co-ordinate:
Public Function NextX() As Single
Dim CN As ADODB.Connection
Dim RS As ADODB.Recordset
Dim DBPath As String
Set CN = New ADODB.Connection
Set RS = New ADODB.Recordset
DBPath = GetSetting("GrisGun", "Settings", "DBLoc")
CN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source = " & DBPath & ";" & _
"Persist Security Info=False"
CN.Open
RS.Open "CurrentGun", CN, adOpenStatic, adLockOptimistic, adCmdTable
RS.AbsolutePosition = CurrentGunPos
NextX = RS!Distance
RS.Close
CN.Close
Set RS = Nothing
Set CN = Nothing
End Function
I've tried it with:
Dim CN as New ADODB.Connection
and with:
Dim CN as ADODB.Connection
Set CN = New ADODB.Connection
the result is the same.
Sometimes this will fail on the third connection to the database, sometimes
on the 60th, or anywhere inbetween. I can't find any reason as to why it
won't connect. And more so, why other functions connecting to the database
won't connect once the error occurs.
Thanks in advance for your help.
James
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks