A
Antonio Ortiz
Client: Access 2000
Server: MSDE 1.0
Error: "Automation error", "Operation is not allowed when the object is
open.".
My function open an connection in code, but OpenConnection method (of
proyect) don't work. (Code is below)
thanks
Antonio Ortiz Ramirez
asesor en sistemas
(e-mail address removed)
www.aortiz.net
www.progvisual.com
Function ConnectProy() As Long
Dim C As String
Dim Cnx As New ADODB.Connection
On Error Resume Next
C = "PROVIDER=SQLOLEDB" & _
";DATA SOURCE=miservidor.dns2go.com" & _
";INITIAL CATALOG=midb" & _
";USER ID=sa" & _
";PASSWORD=" & _
";Network Library=DBMSSOCN"
Cnx.Open C 'Connection Ok
If (Err = 0) Then
Application.CurrentProject.OpenConnection C 'This say Error
If (Err = 0) Then
MsgBox "Connect ok", vbOKOnly + vbInformation, "Hello"
LeeParametros
Else
MsgBox "Error in connection " & vbNewLine & _
Err & ": " & Error, vbOKOnly + vbCritical, "Not connect"
End If
'Application.CurrentProject.Connection.Open C
Else
MsgBox "Error in connection " & vbNewLine & _
Err & ": " & Error, vbOKOnly + vbCritical, "Not connect"
End If
Cnx.Close
Set Cnx = Nothing
End Function
Server: MSDE 1.0
Error: "Automation error", "Operation is not allowed when the object is
open.".
My function open an connection in code, but OpenConnection method (of
proyect) don't work. (Code is below)
thanks
Antonio Ortiz Ramirez
asesor en sistemas
(e-mail address removed)
www.aortiz.net
www.progvisual.com
Function ConnectProy() As Long
Dim C As String
Dim Cnx As New ADODB.Connection
On Error Resume Next
C = "PROVIDER=SQLOLEDB" & _
";DATA SOURCE=miservidor.dns2go.com" & _
";INITIAL CATALOG=midb" & _
";USER ID=sa" & _
";PASSWORD=" & _
";Network Library=DBMSSOCN"
Cnx.Open C 'Connection Ok
If (Err = 0) Then
Application.CurrentProject.OpenConnection C 'This say Error
If (Err = 0) Then
MsgBox "Connect ok", vbOKOnly + vbInformation, "Hello"
LeeParametros
Else
MsgBox "Error in connection " & vbNewLine & _
Err & ": " & Error, vbOKOnly + vbCritical, "Not connect"
End If
'Application.CurrentProject.Connection.Open C
Else
MsgBox "Error in connection " & vbNewLine & _
Err & ": " & Error, vbOKOnly + vbCritical, "Not connect"
End If
Cnx.Close
Set Cnx = Nothing
End Function