Hello Tom,
Thank you for your post. I have implemeted your suggestions and still get the same error message. Here is a copy of my test program.
Imports ADODB
Public Class Form1
Private Con As New ADODB.Connection
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Dim rs As New ADODB.Recordset Dim sql As String = "DELETE FROM DRST WHERE Reference='31460'"
If Not TestConnection(Con) Then MsgBox("Could not establish a connection") End If
With rs .CursorType = CursorTypeEnum.adOpenForwardOnly .LockType = LockTypeEnum.adLockOptimistic .CursorLocation = CursorLocationEnum.adUseServer End With
rs.Open(sql, con)
If rs.State = 1 Then rs.Close() End If
rs = Nothing Catch ex As Exception MsgBox(ex.Message) End Try End Sub
Private Sub Form1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Leave Con.Close() End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Con.ConnectionString = "Data source=imsapps" Con.Open() End Sub
Private Function TestConnection(ByRef Connection As ADODB.Connection) As Boolean Try ' for opening connection to DataFlex
If (Connection Is Nothing) Then Connection = New ADODB.Connection End If
If Connection.ConnectionString <> "DSN=imsapps" Then If Connection.State <> 0 Then Connection.Close() End If Connection.ConnectionString = "DSN=imsapps" Connection.Open() End If
TestConnection = True Catch ex As Exception MsgBox("Invalid DSN Name: " & ex.Message) TestConnection = False End Try End Function End Class
|