-
Datagrid Not Correct
Hello!
I hope i posted the Thread correct!
Something weird is happening in my project. I save 50 pictures with some characteristics(Name, Size, Width, Height.....) in fields in database and all is working fine. Then when i delete one or two or three pictures still everything is fine. The problem comes when after deleting these pictures i save others into the database. When i save them i see in the datagrid that they are saved in the end(everyone in a new record). When i'm leaving this form and go to another that also has a datagrid the order of the picture has changed.
I will try to show it to you!
Pictures in database according to id:
Step1
1->Deleting
2
3
4
5
6
7
8
9
10
After deleting.
2
3
4
5
6
7
8
9
10
After inserting 4 new pictures.
2
3
4
5
6
7
8
9
10
11
12
13
14
Then going to another form. I get this in the datagrid:
2
3
4
5
6
11
12
7
8
9
10
13
14
Whu is that happening? Any ideas? the order of the pictures is ok in the database but in the DataGrid in all forms i get a wrong order!
When i go to another form i use this code:
Code:
MainForm.Show
Form2.Hide
Unload Form2-> Maybe this is wrong?
Thank's!
-
Re: Datagrid Not Correct
You can try:
Select * from <tablename> order by id
then
datagrid1.Refresh
good luck!
-
Re: Datagrid Not Correct
put a order by on your select query
select * from table1 order by id
is id a integer? if it is a char the arrangement willbe
1
11
12
13
14
2
3
4
5
6
7
8
9
-
Re: Datagrid Not Correct
Duplicate threads have been merged.
We ask that you do not double post the same question in different sections even though the question could apply to more than one section.
Thanks.
-
Re: Datagrid Not Correct
Good Idea. I will put the ORDER BY Id ASC in every adodc that i load in all forms!
Let's see what happens!
-
Re: Datagrid Not Correct
Better yet, delete the ADODC components and use ADO code to interface to databases.