Go Back   Forum Care Forums > Development Reference Area > Visual Basic

Reply
 
LinkBack Thread Tools Display Modes
ADO Data Control in VB 6.0
Old
  (#1)
Joe-Paul Robb, Jr.
Guest
 
Posts: n/a
Default ADO Data Control in VB 6.0 - 06-04-2007, 10:32 AM

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


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: ADO Data Control in VB 6.0
Old
  (#2)
Henning
Guest
 
Posts: n/a
Default Re: ADO Data Control in VB 6.0 - 06-04-2007, 10:32 AM


"Joe-Paul Robb, Jr." <EMAIL REMOVED> skrev 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


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: ADO Data Control in VB 6.0
Old
  (#3)
Geoff
Guest
 
Posts: n/a
Default Re: ADO Data Control in VB 6.0 - 06-04-2007, 10:32 AM


"Henning" <EMAIL REMOVED> wrote in message
news:4543d3da$0$32153$EMAIL REMOVED...
>
> "Joe-Paul Robb, Jr." <EMAIL REMOVED> skrev 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 ?


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: ADO Data Control in VB 6.0
Old
  (#4)
JP
Guest
 
Posts: n/a
Default Re: ADO Data Control in VB 6.0 - 06-04-2007, 10:32 AM

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" <EMAIL REMOVED> wrote in message
news:4543d3da$0$32153$EMAIL REMOVED...
>
> "Joe-Paul Robb, Jr." <EMAIL REMOVED> skrev 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
>
>



   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: ADO Data Control in VB 6.0
Old
  (#5)
JP
Guest
 
Posts: n/a
Default Re: ADO Data Control in VB 6.0 - 06-04-2007, 10:32 AM

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" <EMAIL REMOVED> wrote in message
news:454400e2$0$21350$EMAIL REMOVED...
>
> "Henning" <EMAIL REMOVED> wrote in message
> news:4543d3da$0$32153$EMAIL REMOVED...
>>
>> "Joe-Paul Robb, Jr." <EMAIL REMOVED> skrev 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 ?
>
>



   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: ADO Data Control in VB 6.0
Old
  (#6)
Geoff
Guest
 
Posts: n/a
Default Re: ADO Data Control in VB 6.0 - 06-04-2007, 10:32 AM


"JP" <EMAIL REMOVED> wrote 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.




   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: ADO Data Control in VB 6.0
Old
  (#7)
JP
Guest
 
Posts: n/a
Default Re: ADO Data Control in VB 6.0 - 06-04-2007, 10:32 AM

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" <EMAIL REMOVED> wrote in message
news:45468aef$0$2442$EMAIL REMOVED...
>
> "JP" <EMAIL REMOVED> wrote 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.
>
>
>
>



   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: ADO Data Control in VB 6.0
Old
  (#8)
Ralph
Guest
 
Posts: n/a
Default Re: ADO Data Control in VB 6.0 - 06-04-2007, 10:32 AM


"JP" <EMAIL REMOVED> wrote 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 ***igning that as the
DataSource for each of your Adodcs.

-ralph


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top