Results 1 to 6 of 6

Thread: Datagrid Not Correct

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    322

    Question 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!

  2. #2
    New Member
    Join Date
    Feb 2007
    Posts
    8

    Re: Datagrid Not Correct

    You can try:
    Select * from <tablename> order by id
    then
    datagrid1.Refresh
    good luck!

  3. #3
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Philippines
    Posts
    468

    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
    if you have a problem face it
    but what if your face is your problem
    how can you face it

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    322

    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!

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Datagrid Not Correct

    Better yet, delete the ADODC components and use ADO code to interface to databases.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width