Hi,
I created a function that supposedly checks a connection manager if a connection can be established.
When I was testing the code, I found out that the following code always returns "Successful" for flat files and SMTP connection even if the flat file does not even exist or there are no connection parameters for SMTP.
Can you tell me what to use to check if a connection can be established for all types of connection managers?
Here is the function that I created which does not seem to work as I expected:
Public Function connect(ByVal connMgr As Object) As String
Dim connected As String
Try
Dts.Connections(connMgr.name).AcquireConnection(Nothing)
Return "Successful"
Catch ex As Exception
Return "Failure"
Finally
Dts.Connections(connMgr.name).ReleaseConnection(Nothing)
End Try
End Function
Thanks.
AcquireConnection returns an object that represents the connection. You need to check this object. It will be different for each connection manager.
An ADO.NET connection manager will return an IDbConnection object.
The SMTP Connection manager simply returns the connection string of the connection manager.
There isn't a generic way to determine if a connection can be established for all types of connection managers.
|||
A flat file does not need to exist for AcquireConnection to be successful. It can point to a destination file to be created at the runtime.
Thanks.
No comments:
Post a Comment