Hi There,
Bit lost here I haven't used VB for sooo long. I'm trying to make a connection to SQL Server database, I have several queries that are in MS Query that I would like returned to Excel however, I now want a VB front end so that I can pass 1 Date range to all 7 queries and refresh them all together instead of seperately.
I'm trying to get my connection validated first and below is my code:
Public Sub ConnectToDatabase()
Const sSource As String = "ConnectToDatabase"
Dim IAttempt As Long
Dim sConnectCMPW As String
Dim sConnectBPCS As String
'On Error GoTo ErrorHandler
'Create the connection string to database
sConnectCMPW = "DSN=CAMPUSDEVELOPMENT;UID=sa;PWD=9Hyp68a;Database=CAMPUSDEVELOPMENT"
Set CMPW_Connect = New ADODB.Connection
CMPW_Connect.ConnectionString = sConnectCMPW
CMPW_Connect.Open
CMPW_Connect.Close
End Sub
The Error returned is :
Compile Error user defined type not defined on the following line:
Set CMPW_Connect = New ADODB.Connection
Any help much appreciated.
Many thanks
Sam
Bit lost here I haven't used VB for sooo long. I'm trying to make a connection to SQL Server database, I have several queries that are in MS Query that I would like returned to Excel however, I now want a VB front end so that I can pass 1 Date range to all 7 queries and refresh them all together instead of seperately.
I'm trying to get my connection validated first and below is my code:
Public Sub ConnectToDatabase()
Const sSource As String = "ConnectToDatabase"
Dim IAttempt As Long
Dim sConnectCMPW As String
Dim sConnectBPCS As String
'On Error GoTo ErrorHandler
'Create the connection string to database
sConnectCMPW = "DSN=CAMPUSDEVELOPMENT;UID=sa;PWD=9Hyp68a;Database=CAMPUSDEVELOPMENT"
Set CMPW_Connect = New ADODB.Connection
CMPW_Connect.ConnectionString = sConnectCMPW
CMPW_Connect.Open
CMPW_Connect.Close
End Sub
The Error returned is :
Compile Error user defined type not defined on the following line:
Set CMPW_Connect = New ADODB.Connection
Any help much appreciated.
Many thanks
Sam