Results 1 to 4 of 4

Thread: urgent please help me !!!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2004
    Posts
    108

    Unhappy urgent please help me !!!

    i got a problem to add a data to my checkedlistbox the command is like that

    ==============================================
    Try
    conn.Open()
    Dim sql = "SELECT * FROM CustomerBooking WHERE cday='" & Me.day.Text & "' And cmonth='" & Me.month.Text & "' And carrivetime='" & Me.carrivetime.Text & "' And cyear ='" & Me.year.Text & "'"

    cmd = New OleDbCommand(sql, conn)

    Dim dr As OleDbDataReader = cmd.ExecuteReader

    While dr.Read

    Num1 = dr("tablenumber")
    Me.CheckedListBox1.Items.Add(Num1)

    End While

    dr.Close()
    conn.Close()

    Catch ex As Exception
    MsgBox(ex.Message)
    End Try

    ==============================================

    y the result given to me is a duplicate one ??

    example i have 1,2,3 inside my database

    and the checkedlistbox result is 1,2,3,1,2,3 double time

    wat is the problem ?

    please help

  2. #2
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    I don't now much about SQL but I think the problem lies elsewhere.

    I noticed that you do not clear the items in the list before adding.
    So if, for some reason, you function gets called twice it will add them again.

    You can check for this very easily by adding a messagebox on the beginning of the function. Then you can see if that msg comes up twice.

    But I would recommend clearing the items in the list before adding anyway.

    Hope this helps.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  3. #3
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    You'll have to do a DISTINCT query
    Code:
    SELECT DISTINCT tableNumber FROM etc...
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Mar 2004
    Posts
    108
    Thank You I solve the problem already
    thanx for helping me

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