English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I cannot get past the ADOB connect line of this code, even though it is declared:

Compile Error: User-defined type not defined

Option Explicit
Dim X As Long
Dim Changed As Boolean
Dim DontMove As Boolean
Dim tmrSelect As String
Dim strCnn As String
Dim conConnection As New ADODB.Connection
Dim rs As ADODB.Recordset

Set conConnection = New ADODB.Connection
Set rs = New ADODB.Recordset

2007-02-04 01:57:42 · 4 answers · asked by rebjr1954 1 in Computers & Internet Programming & Design

4 answers

Here is a code snippet from what I use. I actually created a class to wrap some of this stuff. There is a little bit of redundancy in the recordset openning routine. You'll need to add your own text within the two statements that use quotes (connection string and sql statement). Your error may occur if you don't have Microsoft ActiveX Data Objects 2.x added as a Reference to your project. (on your menu, Project --> References). I recommend you grab the highest one (2.6 or 2.8).

I have a hint for connection strings after the code sample.

I pasted your code into a blank project and was able to reproduce the error without having this reference. The following text was highlighted: conConnection As New ADODB.Connection, which means that ADODB.Connection is not defined. I added Microsoft ActiveX Data Objects 2.8 to my references then it run, and it had no errors. Anyway, here is the sample code:


' Open connection
Dim cn As New ADODB.Connection

cn.ConnectionString = "put your connection string between these quotes"
cn.CursorLocation = adUseClient
cn.Open

'setup recordset
Dim ado_RS As ADODB.Recordset

Set ado_RS = New ADODB.Recordset
With ado_RS
.ActiveConnection = cn
.Source = "Place your SQL Statement within these quotes"
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open ado_RS.Source _
, ado_RS.ActiveConnection _
, ado_RS.CursorType _
, ado_RS.LockType
End With

If you aren't sure about what connection string to use, you can add a component to your toolbox: Microsoft ADO Data Control 6.0. Add this control to any form then right-click and select "ADODC Properties". In the section that says "Connection String" click on Build. Just follow the steps from there, being sure to hit the "Next" button after each step. When finished, it will return you to the properties form with the connection string in the text box. Copy this out of the text box and paste it into your code where you are establishing the connection string. Don't forget to remove the new component from your project. I personally prefer not to use the form control for this and use the ADODB objects given by the ADO 2.8 objects in references instead.

2007-02-04 06:56:06 · answer #1 · answered by Anonymous · 0 0

Same thing is happening here in Mexico. Call of Duty 4 update took several tries to download. I still can't download the new map pack I'm getting the same error code.Hope xbox live guys fix it soon.

2016-03-29 04:23:01 · answer #2 · answered by ? 4 · 0 0

You need to provide a connection string property which defines what DB you will be using and where it is located then call the Open method Then using this connection object you write a SQL query string and use the connection ans SQL string to return a recordset

conConnection.connectionString ( "STRING GOES HERE)
conConnection.Open

2007-02-04 02:24:00 · answer #3 · answered by MarkG 7 · 0 1

One of your data-types is obviously not defined. I'm guessing that it's your
Dim conConnection as New ADODB.Connection.

Drop the New from it, you can't do that in VB6, but you can in VB.NET.

2007-02-04 02:25:51 · answer #4 · answered by Anonymous · 0 0

fedest.com, questions and answers