Using Table Adapter to Find Record Using MySql and Visual Basic 2008, How Can I Implement it? RRS feed

  • Question

  • I'm trying to retrieve data from MySql from 8) using the following method.

    All goes well for movenext, movefirst, ... etc, but when I try to find
    a record through find() method I don't understand what should type in
    (...), while the intelesense states to type prop and object key. It
    really doesn't make any sens for me. Consider the following table as

    ID               first field              second field         third
    1                 aaa                     bbb                     ccc
    2                 ppp                     qqq                     rrr
    3                 sss                     ttt

    Now how would "Me.bindingsource.find()" statement will be written in
    order to search a specific record(i.e qqq) from the database?

    I am using this code:

                Dim customerID As Integer = CInt(tbBuscar.Text)


    I get an error when I use the storeId variable here: (Too many arguments, error)

                '''Me.StoreTableAdapter.FillByStore(, storeID)


            Catch ex As InvalidCastException
                MessageBox.Show("Customer ID must be an integer.", "Entry Error")
            Catch ex As SqlException
                MessageBox.Show("SQL Server error # " & ex.Number _
                    & ": " & ex.Message, ex.GetType.ToString)
            End Try
    Saturday, June 21, 2008 6:14 AM

All replies


    Private Sub recordbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles recordbtn.Click


    'find and display manager

    'manager is the field in the database

    Dim row As Integer

    Dim value As String = storetxtsearch.Text

    row = StoreBindingSource.Find("manager", value)

    StoreBindingSource.Position = StoreBindingSource.Find("manager", value)

    'Usa esta linea para buscar/search MySql Database ....incluye .....arriba 'Imports MySql.Data.MySqlClient

    Dim MyConString As String = "SERVER=localhost;" + "DATABASE=mystore;" + "UID=root;" + "PASSWORD=;"

    'Declarando la variable y asignando el textbox a esta variable

    Dim tbBuscar As String = storetxtsearch.Text

    Dim micomando As String

    Dim connection As New MySqlConnection(MyConString)

    Dim command As MySqlCommand = connection.CreateCommand()

    Dim Reader As MySqlDataReader

    'Seleccionar todos los empleados

    'command.CommandText = "select manager,city,state from store"

    micomando = "SELECT Employee.lastname, Store.City,Store.State,Store.manager FROM(employee, store)WHERE employee.employeeID=store.storeID"

    command.CommandText = micomando


    Reader = command.ExecuteReader()

    While Reader.Read()

    Dim thisrow As String = ""

    For i As Integer = 0 To Reader.FieldCount - 1

    thisrow += Reader.GetValue(i).ToString() + ","



    End While


    'Esto es un ejemplo de Union de dos tablas

    End Sub

    Thursday, June 26, 2008 1:56 AM