Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 159
  • Last Modified:

ADO Control and MS Access

I have a table called "Personal". Person_Id is one of the fields in the table.
The table is in ascending order by Personal_Id. When I used the MS Access to look at the table. The order is correct.

I have developed a vb form. All the textboxes are binding with ADO Control.
In vb form, the data are displayed in decending order. Why ?
How to make it displays in ascending order ?
0
johnmemor
Asked:
johnmemor
1 Solution
 
Ryan ChongCommented:
Hi, in your SQL in RecordSource, please use "Order By"


Such as:

Adodc1.RecordSource = "Select * from Personal Order By Person_id"

'Hope will help.
0
 
hongjunCommented:
ryancys is correct. You need to use the ORDER BY clause to sort.

hongjun
0
 
johnmemorAuthor Commented:
Where should I put that recordsource ?
Because mt textboxes are binded to the ADO control.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Ryan ChongCommented:
Hu, You can set the RecordSource Property at run time:

Adodc1.RecordSource = "Select * from Personal Order By Person_id"
Adodc1.Refresh
0
 
johnmemorAuthor Commented:
I tried that code, still not correct.
0
 
Ryan ChongCommented:
Hi John, please kindly post your codes.
0
 
Ryan ChongCommented:
and remove the RecordSource 's Text from ADODC control, then try again.
0
 
johnmemorAuthor Commented:
The recordsource in the properties window is Personal. I have removed it, and
still not correct.

For example, if I have entered the following person_id in this order :

  120, 34, 344, 20

In the MS Access, you will see the person_id is in ascending order.
But in the vb form, it is 20, 344, 34,120
0
 
Ryan ChongCommented:
What is the data type of person_id?
0
 
johnmemorAuthor Commented:
int
0
 
mmcmillenCommented:
is there a index associated with that table?  Idont know much about the bound data control because I dont use it, but when you define the connection or database do you define the primary index for it?  

0
 
Ryan ChongCommented:
Hi, please check the Controls on how you bound in with ADODC control, as well as the SQL.

The "Order By" clause is definitely correct to sort your tables ascendingly.
0
 
johnmemorAuthor Commented:
no, I don't have index
0
 
TimCotteeCommented:
John, lets keep it simple(ish) at this stage. On the RecordSource tab of the properties dialog for the ADO Data Control. Set the CommandType to "1 - adCmdText" and in the Command Text (SQL) box place "Select * from Personal Order By Person_id ASC". This should then return the data correctly ordered for you. Of course you can do some or all of this through code assignement as well however to get you started it may be easiest to use the control in this way.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now