ADO, Datagrid, Refresh after change Commandtext 
Author Message
 ADO, Datagrid, Refresh after change Commandtext

Hi,
I switched from VB3 to VB6 and try to use the new ADO by using a
datagrid to display the results of a design-time Command. This works
great but how can I refresh a datagrid when I change the underlying
Commandtext (or change the value of an associated CommandParameter) ??
I tried:
cmdABC.Execute
Datagrid.Refresh
but nothing changes on my screen.

I also tried another approach by creating a new Command and tried to
change the Datagrid.Datamember but this property only accepts a string
(being the name of a command given during design time). So I can't
change the underlying data of the datagrid.

Almost all examples in the help text take the route using a Recordset
for the result of a Command. Although I can get that to work, I don't
want to use that, otherwise I will be stuck again reading Recordsets
from front to end, filling list boxes. I thought a datagrid would be
an elegant way to skip Recordsets. In my application I only need to
display data, no updates/adds are necessary.
Who can help me or tell me that what I want is impossible ?
Regards,
Peter



Fri, 30 Mar 2001 03:00:00 GMT
 ADO, Datagrid, Refresh after change Commandtext

You may want to try the Requery method instead, this is a problem with
ADO, it accepts the old DAO Refresh syntax, but alas, does nothing.

You will need to make sure the connection and recorset is open so your
code may look like this:

On Error goto Err
Connection1.rscmdABC.Open
Connection1.rscmdABC.Requery
Exit Sub

Err:
'If the connection is already open, then just refresh the data

Connection1.rscmdABC.Requery

End Sub

Notice that ADO Commands as converted to Recordsets, so just type in
your ADO Connection Name, Connection1.rs then watch all those SQL
Queries and Commands list out as recordsets as well.. Henry


Quote:

>Hi,
>I switched from VB3 to VB6 and try to use the new ADO by using a
>datagrid to display the results of a design-time Command. This works
>great but how can I refresh a datagrid when I change the underlying
>Commandtext (or change the value of an associated CommandParameter) ??
>I tried:
>cmdABC.Execute
>Datagrid.Refresh
>but nothing changes on my screen.

>I also tried another approach by creating a new Command and tried to
>change the Datagrid.Datamember but this property only accepts a string
>(being the name of a command given during design time). So I can't
>change the underlying data of the datagrid.

>Almost all examples in the help text take the route using a Recordset
>for the result of a Command. Although I can get that to work, I don't
>want to use that, otherwise I will be stuck again reading Recordsets
>from front to end, filling list boxes. I thought a datagrid would be
>an elegant way to skip Recordsets. In my application I only need to
>display data, no updates/adds are necessary.
>Who can help me or tell me that what I want is impossible ?
>Regards,
>Peter



Fri, 30 Mar 2001 03:00:00 GMT
 
 [ 2 post ] 

 Relevant Pages 

1. Refreshing Datagrid after param change

2. How to refresh ado datagrid

3. ADO : How to refresh a DATAGRID ?

4. How to refresh ado datagrid

5. How to refresh ado datagrid

6. DataGrid (ADO) refresh

7. ADO - Refreshing Datagrid

8. ADO Datagrid refresh problems

9. Stored procedures, CommandText and unwanted Parameters.Refresh

10. Updating an ADO recordset from user-changed data in DataGrid

11. dataenvironment, connection, commandtext can i change it?

12. Changing CommandText During RunTime?


 
Powered by phpBB® Forum Software