ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   compile error... ADODB connection (https://www.excelbanter.com/excel-programming/359136-compile-error-adodb-connection.html)

ina

compile error... ADODB connection
 
Hello all,

I have a problem with the ADODB connection... and I do not understand
because yesteday worked fine and today not.

I have this mistake ...

compile error, User-defined type not defined

This is my code

Sub test()

'---------------------------------------
'Connection to sql server
'---------------------------------------
'Set up a connection
Set Cnx = New ADODB.Connection

Dim cmd As ADODB.Command ...

Thanks,

ina


Jim Thomlinson

compile error... ADODB connection
 
As a guess you have not got a reference to the ADODB library. Look in Tools
- References for an item marked as missing "Missing: Microsoft ActiveX Data
Objects..." Uncheck this item and find a version of that library that you do
have.

As an aside, you should declare your connection object with a dim statement
something like this...

Sub test()
Dim Cnx as ADODB.Connection
'---------------------------------------
'Connection to sql server
'---------------------------------------
'Set up a connection
Set Cnx = New ADODB.Connection

Dim cmd As ADODB.Command ...

--
HTH...

Jim Thomlinson


"ina" wrote:

Hello all,

I have a problem with the ADODB connection... and I do not understand
because yesteday worked fine and today not.

I have this mistake ...

compile error, User-defined type not defined

This is my code

Sub test()

'---------------------------------------
'Connection to sql server
'---------------------------------------
'Set up a connection
Set Cnx = New ADODB.Connection

Dim cmd As ADODB.Command ...

Thanks,

ina



ina

compile error... ADODB connection
 
Thanks I did it and it works :)
Ina



All times are GMT +1. The time now is 08:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com