Results 1 to 4 of 4

Thread: Listbox_click (Solved)

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2004
    Posts
    43

    Listbox_click (Solved)

    having some problems with my codings.. not sure what had happened.. it goes like this.....

    "
    'This function is to pupolate all fields with informations from database by clicking on selected item on listbox
    Private Sub ListBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
    Dim objDataReader As OleDbDataReader
    Dim objCommand As OleDbCommand
    objCommand = New OleDbCommand
    objCommand.Connection = conn
    objCommand.CommandText="select * from Hardware where TagNo= ' " + ListHardware.SelectedItems.ToString + " ' "
    Try
    objDataReader = objCommand.ExecuteReader
    Catch ex As Exception
    MsgBox(ex.ToString)
    End Try
    objDataReader.Read()
    TxtTagNo.Text = objDataReader("TagNo")
    objDataReader.Close()
    End Sub

    "

    after running the program, the problem it show is..
    " System.Data.OleDb.OleDbException: Data type mismatch in criteria expression."

    as for "TagNo" in my access database, its an autonumber.

    however, this codings works if i never include 'where TagNo= '"+ ListHardware.selecteditem.tostring+"'" ' then all field is populated with information but its just only the 1st record and i could not display other record when i click on different item on the listbox..
    hmmm.. i guess the problems is with my SQL statement... but im not sure...

    is there any solution for this? Please help!!!!
    Last edited by ralphz; Sep 7th, 2004 at 09:07 AM.

  2. #2
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416
    what is the item in your listbox?
    is it a number or what???
    if it is not a number it will throw an error coz your statement referencing to a tagno...

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2004
    Posts
    43

    Talking

    its a number.. anyway it had been solved...
    thanks alot mar_zim..!

  4. #4
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416
    ok..edit your subject line put (Solved)
    Last edited by mar_zim; Sep 7th, 2004 at 01:41 AM.

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