Page 1 of 1

What is wrong here

Posted: Wed Dec 14, 2011 10:56 pm
by Kobra1984
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

Re: What is wrong here

Posted: Wed Dec 14, 2011 10:59 pm
by muttley1968
please give more info hows this being used n whats it for

Re: What is wrong here

Posted: Wed Dec 14, 2011 11:03 pm
by Kobra1984
updated

Re: What is wrong here

Posted: Wed Dec 14, 2011 11:09 pm
by muttley1968
ohh well there should be a data source somewhere i would think and whats the error there is no error in that just code

Re: What is wrong here

Posted: Wed Dec 14, 2011 11:11 pm
by Kobra1984
error is
Unknown column 'accounts.EMail' in 'field list'

Re: What is wrong here

Posted: Wed Dec 14, 2011 11:13 pm
by muttley1968
Check capitalization then if i were you or change field name


PS Plz look and comment on my program
viewtopic.php?f=38&p=59866#p59866

Re: What is wrong here

Posted: Wed Dec 14, 2011 11:24 pm
by Kobra1984
no thanks

Re: What is wrong here

Posted: Thu Dec 15, 2011 1:09 am
by mandai
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.