4

There is compile error 'user-defined type not defined' I get in VB6 when I was tried to compile this code. Can anybody tell me what I need to do to solve this error? Following is the line for which I got the error:

Public Conn As ADODB.Connection

Public rs As ADODB.Recordset
Mike G
  • 4,232
  • 9
  • 40
  • 66
bella
  • 51
  • 1
  • 1
  • 2
  • Have you included in project a reference to Microsoft ActiveX Data Objects? – MC ND Dec 03 '13 at 21:03
  • Possible duplicate of ['User Defined Type Not Defined' error](http://stackoverflow.com/questions/24261557/user-defined-type-not-defined-error) – Zev Spitz Dec 29 '16 at 08:39

1 Answers1

12

You need to add the reference to the ADO type library:

  1. Open your project.
  2. Click the Project menu item, then select References...
  3. From Available References, check the box next to Microsoft ActiveX Data Objects n.n Library, where n.n is one of the following:
    • 6.1 - if you want your application to run only on Windows 7 or later
    • 2.8 - if you want your application to run on Windows XP or later
  4. Click OK.

You may also want to look at Referencing the ADO Libraries In a Visual Basic 6 Application from the ADO Programmer's Guide.

Holistic Developer
  • 2,458
  • 1
  • 18
  • 27