PDA

Click to See Complete Forum and Search --> : Disconnected data in DataGrid?


msuryadarma
Nov 8th, 2000, 08:26 AM
Hi all,

Ok, so I have ADODC and a DataGrid. The DataGrid displays the query result that I put in.

Now my question is, is it possible do manipulate (sort, etc) what's in the DataGrid without sending more queries into the Database? In other words, is it possible to treat that data inside the DataGrid as disconnected data?

I know it's possible if I use recordsets and such, but can I do it without?

If I HAVE to use recordsets, and my recordset variable is rs, can I just do "DataGrid1.DataSource = rs"? Is this possible?

Thanks a lot!!

Lafor
Nov 9th, 2000, 08:54 AM
U get a disconnected a recordset by setting your .ActiveConnection to Nothing once you get your recordset....

The cursor service then alllows you to do anything with your recordset...

make any changes without connecting to the db...

and if you want to update any the db with any of your changes later on...

use .resync

good luck

msuryadarma
Nov 9th, 2000, 09:09 AM
Lafor,

Thanks for the reply. Ok one question. What if I want to sort the data in the datagrid?

How do I do that with the cursor service? Because that means I have to Query the disconnected data. Can I do that?

Thanks!!

Lafor
Nov 9th, 2000, 09:13 AM
The cursor service is just Microsoft's term to allow one
to do all this stuff...

You invoke it when you set your
.cursorlocation to aduseclient

note once u have the disconnected recordset
you can do anything you want

If you want to sort your datagrid

sort the underlying recordset
and reload the data grid with that recordset
and refresh it...

am i making sense?

msuryadarma
Nov 9th, 2000, 09:24 AM
Lafor,

Yes you are making sense.

But can you show an example of the command to "sort the underlying recordset"?

How exactly do I do it? Do I do a SELECT * FROM Data1.RecordSet ORDER BY ...?

Thanks! Sorry that I have to ask so many questions.

Lafor
Nov 9th, 2000, 09:26 AM
Read your question again... Was not sure whether you were asking for the following...

... (from the help files)


Specifies one or more field names the Recordset is sorted on, and whether each field is sorted in ascending or descending order.

Settings and Return Values

Sets or returns a String of comma-separated field names to sort on, where each name is a Field in the Recordset, and is optionally followed by a blank and the keyword ASCENDING or DESCENDING, which specifies the field sort order.

Remarks

The data is not physically rearranged, but is simply accessed in the sorted order.

A temporary index will be created for each field specified in the Sort property if the CursorLocation property is set to adUseClient and an index does not already exist.

Setting the Sort property to an empty string will reset the rows to their original order and delete temporary indexes. Existing indexes will not be deleted.

Lafor
Nov 9th, 2000, 09:31 AM
Our msgs crossed...

Ex..

Set cmd.ActiveConnection = conncmd.CommandText = "SELECT * from authors"'
rs.CursorLocation = adUseClient
rs.Open cmd, , adOpenStatic, adLockBatchOptimistic'

---THIS LINE AN INDEX ON LAST NAME (IF U WANT TO SPEED
--SEARCHES (of DISC RECORDSET)
rs!au_lname.Properties("Optimize") = True

rs.Sort = "au_lname"

etc...

If u want to sort by more fields

rs.sort = "au_lname, next field,...etc"

msuryadarma
Nov 9th, 2000, 09:37 AM
Lafor,

That's what I want, that's what I need. Thanks a lot bud!!

I can't believe it took forever for me to figure something simple like this. I have MSDN too, but I couldnt find the thing in there. Thanks a lot again. Have a nice day.

Martin