|
-
Jun 3rd, 2002, 06:09 PM
#1
DBGrid & Data Collection question
Hi everyone. I have a question that's been bugging me and I can't find much on how to resolve it.
I have a Data collection (object) linked with a DBGrid object accessing a database. (Note: I'm having to modify someone else's code to do this, too.) The code is a simple SQL statement, such as:
DBData.RecordSource = "Select * from TABLE where ID = " & ID
DBData.Refresh
This data is put into the attached DBGrid, with no real problems. I'm not sure exactly how it works, but it appears that the latest additions are placed last. What I want to do is reverse the order of the list, so what used to be at the bottom of the DBGrid should be at the top.
I have tried the statement:
DBData.RecordSource = "Select * from TABLE where ID = " & ID & " ORDER by 'PRIMARY KEY' DESC"
but that doesn't seem to do anything.
I don't think I can do this by SQL, that I know of, since I don't know how it's sorting it, or what it's sorting by. Is there a command that will let me reverse the order of the data for either the Data collection or the DBGrid?
Any help is greatly appreciated. 
Destined
Edit: Oh, I figured out that 'PRIMARY KEY' doesn't seem to work. I should also point out that I don't have access to the database itself, so I can't really open it and see what the name of the primary key is.
-
Jun 4th, 2002, 02:03 PM
#2
Just an update: I did manage to figure out how to fix it. It seems that the other person was hiding a couple of extra fields, but (somehow) managed to (thank god) put the name of the hidden fields in as well.
Oh, and in case anyone is searching this and needs help, here's how I found to automatically select (highlight) a row without the user selecting it. (I needed this so the user didn't have to click the most recent db addition...)
VB Code:
' First, move to the row you want
Data1.Recordset.MoveFirst
' Now highlight the row
DBGrid1.SelBookmarks.Add Data1.Recordset.Bookmark
Strangely, it's that simple. Hope this helps out other people later on. 
Destined
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|