Start New Discussion within our Software Development Community

Right I have this so far. I'm trying to implement a search function for example so when you enter information into txtprename.text and press button 4 it will search for that name and return the values of its location etc.

So far for this funciton I have:

Private Sub PrescriberSearch()

               pre.SelectCommand = New MySqlCommand("SELECT * FROM Prescriber WHERE Name = ?Name")

        pre.SelectCommand.Connection = conn

        pre.SelectCommand.Parameters.Add("?Name", MySqlDbType.VarChar, 50, "Name")

        pre.SelectCommand.Parameters.Add("?Location", MySqlDbType.VarChar, 70, "Location")

        pre.SelectCommand.Parameters.Add("?Telephone", MySqlDbType.VarChar, 70, "Telephone")

        pre.SelectCommand.Parameters.Add("?Prescriber_ID", MySqlDbType.Int16, 5, "Prescriber_ID")


    End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

    End Sub

Private Sub PrescriberFieldS()

        txtprename.Text = pr.Tables(0).Rows(intCurrentIndex).Item("Name").ToString()

        txtLocation.Text = pr.Tables(0).Rows(intCurrentIndex).Item("Location").ToString()

        txtPhone.Text = pr.Tables(0).Rows(intCurrentIndex).Item("Telephone").ToString()

        txtpreid.Text = pr.Tables(0).Rows(intCurrentIndex).Item("Prescriber_ID").ToString()

    End Sub

Thanks for your help!

MySqlCommand("SELECT * FROM Prescriber WHERE Name = '?Name'") 'Added the " ' " apostrophized character...
This article has been dead for over six months. Start a new discussion instead.