{ Learn Code. Share Code. Teach Code. Love Code. }

  • What is wrong here

 #59867  by Kobra1984
 Wed Dec 14, 2011 10:56 pm
Code: Select all
Private Sub searchbox_TextChanged(sender As System.Object, e As System.EventArgs) Handles searchbox.TextChanged
        If searchby.Text = "Username" Then
            searchstr = "SELECT accountinfo.fname, accountinfo.lname, accounts.EMail " & _
                "FROM accountinfo WHERE Username like '%" & searchbox.Text & "%'"
        ElseIf searchby.Text = "Email" Then
            searchstr = "SELECT * FROM accounts WHERE EMail like '%" & searchbox.Text & "%'"
        ElseIf searchby.Text = "Last Name" Then
            searchstr = "SELECT * FROM accountinfo WHERE lname like '%" & searchbox.Text & "%'"
        ElseIf searchby.Text = "Phone" Then
            searchstr = "SELECT * FROM accountinfo WHERE phone like '%" & searchbox.Text & "%'"
        End If
        Dim fname, lname, EMail
        CONNECTION.Open()
        cmd = New MySqlCommand(searchstr, CONNECTION)
        dr = cmd.ExecuteReader()
        ListView1.Items.Clear()

        Do While dr.Read()

            fname = (dr.Item("fname").ToString())
            lname = (dr.Item("lname").ToString())
            EMail = (dr.Item("EMail").ToString())


            Dim lv As ListViewItem = ListView1.Items.Add(fname)
            lv.SubItems.Add(lname)
            lv.SubItems.Add(EMail)
        Loop
        dr.Close()
        CONNECTION.Close()
        cmd.Dispose()
    End Sub
Getting this error
mysql tables are accounts and accountinfo

accounts as the EMail in it
and accountinfo as fname and lname
Last edited by Kobra1984 on Wed Dec 14, 2011 11:07 pm, edited 2 times in total.
 #59870  by muttley1968
 Wed Dec 14, 2011 11:09 pm
ohh well there should be a data source somewhere i would think and whats the error there is no error in that just code
 #59880  by mandai
 Thu Dec 15, 2011 1:09 am
Do you have a column named EMail in the accounts table?

Does the error occur when searching in a specific column?

The error message does not show enough information.