appear in the textbox data from other fields

lutonian

Member
Joined
Apr 5, 2013
Messages
16
Programming Experience
Beginner
Good afternoon,

I am new to programming issues, I am slowly doing stuff.

I need a help, it sure is easy for many of you but for me, even with the help of san san google or youtube I have not found a way to make it work.

I created a Windows Form form, with a combobox. The windows form is connected to a mysql database, eg

Imports MySql.Data.MySqlClient
Imports MySql.Data

Public Class Update_page
    Public dset As New System.Data.DataSet
    Public strSQL As String
    Public cmd As New MySqlCommand
    As Dreader Public MySqlDataReader
       As New MySqlConnection Public sConnection

    Update_Load Private Sub (ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'This line of code loads data into the table' BiblotecaDataSet.Libros' You can move or remove it as needed.
        Form1.LibrosTableAdapter.Fill (Form1.BiblotecaDataSet.Libros)

        If sConnection.State = ConnectionState.Closed Then
             sConnection.ConnectionString = "SERVER = my_server; USERID =My_id; PASSWORD = My_password; DATABASE = Bibloteca;"
            sConnection.Open ()
            'MessageBox.Show ("Connected to server")
        Else
            'Catch ex As MySqlException
            MessageBox.Show ("Not connected to server")
            'End Try
        End If
        Combo ()
     End Sub

------- I created a function for the combo box where I taught the book titles table in the combo box.
    Public Sub Combo ()
        Dim da As New MySqlDataAdapter
        Dim ds As New DataSet
        dset.EnforceConstraints = False
    
        strSQL = "SELECT Title FROM Books"

        cmd = New MySqlCommand ()
        cmd.CommandText = strSQL
        cmd.CommandType = CommandType.Text
        cmd.Connection = sConnection

        ds = New DataSet ()
        da.SelectCommand = cmd
        da.Fill (ds, "Books")
        Titulo_combo.DataSource = ds.Tables (0)
        Titulo_combo.DisplayMember = "Title"
    End Sub

My intention is to select from the combo box, with a method combo_change for example, automatically appear in the textbox data from other fields of the database, eg

ID_text = field "Id" in mysql
Desc_text = field "Desc" in mysql
Prestado_text = field "borrowed" in mysql
Quien_text = field "who" in mysql

For then through a button "Update" to save the data on the server.

I hope I have understood,
Thank you very much to all,
 
Last edited by a moderator:
Back
Top