Hello,
I have a program (which works well) that I am modifying. The program sets up a connection to an SQL database using an ODBC connection.
The modifications are to determine which version of SQL is being used. The result will affect how certain items are accessed and displayed. The problem is how to I connect to SQL when I don't yet have the information needed to connect to SQL.
Here is essentially what I am looking for.
I hope this is clear. If not, I can try to explain further.
Thanks.
I have a program (which works well) that I am modifying. The program sets up a connection to an SQL database using an ODBC connection.
The modifications are to determine which version of SQL is being used. The result will affect how certain items are accessed and displayed. The problem is how to I connect to SQL when I don't yet have the information needed to connect to SQL.
Here is essentially what I am looking for.
Code:
Public Function SQLVersion() As Long
' Verify the SQL version being used.
Dim l_strSQl As String
Dim rs As ADODB.Recordset
Dim CONN As ADODB.Connection
On Error GoTo ERR_Handler
Set CONN = New ADODB.Connection
Set rs = New ADODB.Recordset
l_strSQl = "SELECT SERVERPROPERTY('productversion') As Version;"
rs.Open l_strSQl, CONN, adOpenForwardOnly, adLockOptimistic, adCmdText
If Not (rs.BOF And rs.EOF) Then
rs.MoveFirst
SQLVersion = rs.Fields("Version")
End If
rs.Close
Set rs = Nothing
Exit Function
ERR_Handler:
Msgbox(err.description)
End Function
I hope this is clear. If not, I can try to explain further.
Thanks.