By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,966 Members | 812 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,966 IT Pros & Developers. It's quick & easy.

ADO Data Control in VB 6.0

P: n/a
Hello:

I am building a program in Visual Basic 6.0. (Op Sys: Windows XP 2002
Service Pack 2)

I placed an AOD Data Control on a form...and a data Grid. I bound the data
grid to the data control. Then used the following code to populate the data
control ...and thus, the grid:

With datPos
.ConnectionString = stConn
.RecordSource = sPosSQL
.Refresh
End With

stConn is the connection string
sPosSQL is the SQL Statement
Then I refresh the data control

I used the exact same language on a different form it the same program...and
it works fine. I put it on this new form and I get the following error:
[ADODC]: Unknown error. [ADO];
Press "OK" and I get:
Run-time error '-2147467259 (80004005)'"
Method 'Refresh' of object "IAdodc' failed

To check out my SQL and be sure there was no error. I defined a
DAO.Recordset. and opened the recordset using set MyRST =
SUDB.OpenRecordset(sPosSQL) and it opens... etc.

Does anyone have any idea why I'm getting that "unknown" error with the
program works elsewhere.

Thanks...

JP
Oct 27 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a

"Joe-Paul Robb, Jr." <jp****@seniortrans.comskrev i meddelandet
news:71u0h.51$mX4.14@trndny03...
Hello:

I am building a program in Visual Basic 6.0. (Op Sys: Windows XP 2002
Service Pack 2)

I placed an AOD Data Control on a form...and a data Grid. I bound the
data
grid to the data control. Then used the following code to populate the
data
control ...and thus, the grid:

With datPos
.ConnectionString = stConn
.RecordSource = sPosSQL
.Refresh
End With

stConn is the connection string
sPosSQL is the SQL Statement
Then I refresh the data control

I used the exact same language on a different form it the same
program...and
it works fine. I put it on this new form and I get the following error:
[ADODC]: Unknown error. [ADO];
Press "OK" and I get:
Run-time error '-2147467259 (80004005)'"
Method 'Refresh' of object "IAdodc' failed

To check out my SQL and be sure there was no error. I defined a
DAO.Recordset. and opened the recordset using set MyRST =
SUDB.OpenRecordset(sPosSQL) and it opens... etc.

Does anyone have any idea why I'm getting that "unknown" error with the
program works elsewhere.

Thanks...

JP

If the ADO control is on another Form, are you referencing the control on
the correct path (Form)?

/Henning
Oct 28 '06 #2

P: n/a

"Henning" <co***********@coldmail.comwrote in message
news:45***********************@news3.bahnhof.se...
>
"Joe-Paul Robb, Jr." <jp****@seniortrans.comskrev i meddelandet
news:71u0h.51$mX4.14@trndny03...
Hello:

I am building a program in Visual Basic 6.0. (Op Sys: Windows XP 2002
Service Pack 2)

I placed an AOD Data Control on a form...and a data Grid. I bound the
data
grid to the data control. Then used the following code to populate the
data
control ...and thus, the grid:

With datPos
.ConnectionString = stConn
.RecordSource = sPosSQL
.Refresh
End With

stConn is the connection string
sPosSQL is the SQL Statement
Then I refresh the data control

I used the exact same language on a different form it the same
program...and
it works fine. I put it on this new form and I get the following error:
[ADODC]: Unknown error. [ADO];
Press "OK" and I get:
Run-time error '-2147467259 (80004005)'"
Method 'Refresh' of object "IAdodc' failed

To check out my SQL and be sure there was no error. I defined a
DAO.Recordset. and opened the recordset using set MyRST =
SUDB.OpenRecordset(sPosSQL) and it opens... etc.

Does anyone have any idea why I'm getting that "unknown" error with the
program works elsewhere.

Thanks...

JP
If the ADO control is on another Form, are you referencing the control on
the correct path (Form)?

/Henning
DAO.Recordset with ADO control ?
Oct 29 '06 #3

P: n/a
JP
Yes, I'm referring to the correct control... It is on a form...and called
datPOS. The other control on the other form is "datDep"... so I am
referring to the correct control
"Henning" <co***********@coldmail.comwrote in message
news:45***********************@news3.bahnhof.se...
>
"Joe-Paul Robb, Jr." <jp****@seniortrans.comskrev i meddelandet
news:71u0h.51$mX4.14@trndny03...
>Hello:

I am building a program in Visual Basic 6.0. (Op Sys: Windows XP 2002
Service Pack 2)

I placed an AOD Data Control on a form...and a data Grid. I bound the
data
>grid to the data control. Then used the following code to populate the
data
>control ...and thus, the grid:

With datPos
.ConnectionString = stConn
.RecordSource = sPosSQL
.Refresh
End With

stConn is the connection string
sPosSQL is the SQL Statement
Then I refresh the data control

I used the exact same language on a different form it the same
program...and
>it works fine. I put it on this new form and I get the following error:
[ADODC]: Unknown error. [ADO];
Press "OK" and I get:
Run-time error '-2147467259 (80004005)'"
Method 'Refresh' of object "IAdodc' failed

To check out my SQL and be sure there was no error. I defined a
DAO.Recordset. and opened the recordset using set MyRST =
SUDB.OpenRecordset(sPosSQL) and it opens... etc.

Does anyone have any idea why I'm getting that "unknown" error with the
program works elsewhere.

Thanks...

JP

If the ADO control is on another Form, are you referencing the control on
the correct path (Form)?

/Henning


Oct 30 '06 #4

P: n/a
JP
Yes... using a DAO Recordset and setting it to a DAO Recordset. I can just
define it as a "Recordset" rather than a "DAO.Recordset" and get the same
thing. The control on the other form has a recordset "DAO.Recordset" and it
is set to the control and works fine.

"Geoff" <No****@No.comwrote in message
news:45***********************@news.zen.co.uk...
>
"Henning" <co***********@coldmail.comwrote in message
news:45***********************@news3.bahnhof.se...
>>
"Joe-Paul Robb, Jr." <jp****@seniortrans.comskrev i meddelandet
news:71u0h.51$mX4.14@trndny03...
Hello:

I am building a program in Visual Basic 6.0. (Op Sys: Windows XP 2002
Service Pack 2)

I placed an AOD Data Control on a form...and a data Grid. I bound the
data
grid to the data control. Then used the following code to populate the
data
control ...and thus, the grid:

With datPos
.ConnectionString = stConn
.RecordSource = sPosSQL
.Refresh
End With

stConn is the connection string
sPosSQL is the SQL Statement
Then I refresh the data control

I used the exact same language on a different form it the same
program...and
it works fine. I put it on this new form and I get the following
error:
[ADODC]: Unknown error. [ADO];
Press "OK" and I get:
Run-time error '-2147467259 (80004005)'"
Method 'Refresh' of object "IAdodc' failed

To check out my SQL and be sure there was no error. I defined a
DAO.Recordset. and opened the recordset using set MyRST =
SUDB.OpenRecordset(sPosSQL) and it opens... etc.

Does anyone have any idea why I'm getting that "unknown" error with the
program works elsewhere.

Thanks...

JP

If the ADO control is on another Form, are you referencing the control on
the correct path (Form)?

/Henning
DAO.Recordset with ADO control ?


Oct 30 '06 #5

P: n/a

"JP" <jp****@seniortrans.comwrote in message
news:Ndo1h.2192$B44.827@trndny07...
Yes, I'm referring to the correct control... It is on a form...and called
datPOS. The other control on the other form is "datDep"... so I am
referring to the correct control
Well the ADO data control is designed to work with ADO, not DAO.
Are you sure both forms are using tha ADO control with DAO.
When you hover your mouse over the toolbar .
The DAO dataControl displays DATA1, the ADO displays ADODC.
I suggest you start by using the DATA1 control with DAO.
or ditch the DAO.Recordsets & use ADO.Recordsets with
the ADO Control
Regards G.


Oct 30 '06 #6

P: n/a
JP
Geoff...

The help file shows that the ADO Recordsource can be an SQL Statement.
That's what I've tried to execute. In the example I gave... I ran a DAO
recordset to see if the SQL was correct. It was. The actual code is:

Private Sub GetPositions(lgDeptID As Long, lgLocID As Long)
Dim sPositSQL As String

sPositSQL = "SELECT [Position Table].LocationID, [Position
Table].DepartID, "
sPositSQL = sPositSQL & "[Position Table].Position "
sPositSQL = sPositSQL & "From [Position Table] "
sPositSQL = sPositSQL & "Where ((([Position Table].LocationID) = " &
lgLocID & ") And "
sPositSQL = sPositSQL & "(([Position Table].DepartID) = " & lgDeptID &
")) "
sPositSQL = sPositSQL & "ORDER BY [Position Table].Position; "

With datPosit
.ConnectionString = stConn
.RecordSource = sPositSQL
.Refresh
End With

End Sub

As you can see, there is no DAO here. I'm just trying to put the
"recordsource" (SQL) as the recordset to be used in the control.

I need a grid and am using the DataGrid which requires the ADODC. On my
tool bar, when I run my mouse over the other data control, it says "Data"
and that will not display as an appropriate datasource for the DataGrid.

I'm not using DAO for any ADODC control on any form... I'm using SQL
Statements as the Recordsource.

JP
"Geoff" <No****@No.comwrote in message
news:45**********************@news.zen.co.uk...
>
"JP" <jp****@seniortrans.comwrote in message
news:Ndo1h.2192$B44.827@trndny07...
>Yes, I'm referring to the correct control... It is on a form...and called
datPOS. The other control on the other form is "datDep"... so I am
referring to the correct control
Well the ADO data control is designed to work with ADO, not DAO.
Are you sure both forms are using tha ADO control with DAO.
When you hover your mouse over the toolbar .
The DAO dataControl displays DATA1, the ADO displays ADODC.
I suggest you start by using the DATA1 control with DAO.
or ditch the DAO.Recordsets & use ADO.Recordsets with
the ADO Control
Regards G.


Oct 31 '06 #7

P: n/a

"JP" <jp****@seniortrans.comwrote in message
news:hZK1h.5395$dx4.5294@trndny05...
Geoff...

The help file shows that the ADO Recordsource can be an SQL Statement.
That's what I've tried to execute. In the example I gave... I ran a DAO
recordset to see if the SQL was correct. It was. The actual code is:

Private Sub GetPositions(lgDeptID As Long, lgLocID As Long)
Dim sPositSQL As String

sPositSQL = "SELECT [Position Table].LocationID, [Position
Table].DepartID, "
sPositSQL = sPositSQL & "[Position Table].Position "
sPositSQL = sPositSQL & "From [Position Table] "
sPositSQL = sPositSQL & "Where ((([Position Table].LocationID) = " &
lgLocID & ") And "
sPositSQL = sPositSQL & "(([Position Table].DepartID) = " & lgDeptID &
")) "
sPositSQL = sPositSQL & "ORDER BY [Position Table].Position; "

With datPosit
.ConnectionString = stConn
.RecordSource = sPositSQL
.Refresh
End With

End Sub

As you can see, there is no DAO here. I'm just trying to put the
"recordsource" (SQL) as the recordset to be used in the control.

I need a grid and am using the DataGrid which requires the ADODC. On my
tool bar, when I run my mouse over the other data control, it says "Data"
and that will not display as an appropriate datasource for the DataGrid.

I'm not using DAO for any ADODC control on any form... I'm using SQL
Statements as the Recordsource.

JP
The problem is with your connection string. Perhaps it is opening the
database with 'exclusive' rights or some other restriction?

Try creating one adodb.connection object and assigning that as the
DataSource for each of your Adodcs.

-ralph
Oct 31 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.