Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8745519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:01:56+00:00 2026-06-13T12:01:56+00:00

A little tip or help would be very much appreciated, please and thank you.

  • 0

A little tip or help would be very much appreciated, please and thank you.

I have a DataBound ComboBox from my MySql table named "formmaintenance" which has 3 columns namely FormCode, FormName, FormDescription, Combobox DisplayMember is FormCode and ValueMember is FormCode as well, I have 2 TextBoxes named as txtName and txtDesc.

What I would like to happen is when I select an item in Combobox (ex: form101) I want to display the value of FormName of selected item (ex name: Paper) on txtName and FormDescription on txtdesc.

I have yet to know how to start with this, since I’m really new with Vb.Net.

Here is my Code(Updated)

 If conn.State = ConnectionState.Closed Then
            conn.ConnectionString = "Server = localhost; Username= root; Password =; Database =forms"
            Try
                conn.Open()
                MsgBox("Connection Established")
                Dim dt As New DataTable

                Dim sql = "SELECT FormName FROM formma WHERE  FormCode = '" & cmbCode.Text & "';"
                Dim Result As String


                cmd.Connection = conn
                cmd.CommandText = sql
                Result = cmd.ExecuteScalar()
                da.SelectCommand = cmd

                dr = cmd.ExecuteReader()

                If Result IsNot Nothing Then
                    txtName.Text = Result.ToString()

                End If

            Catch ex As MySqlException
                Console.WriteLine("Error: " & ex.ToString())

            End Try
        End If

    End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:01:59+00:00Added an answer on June 13, 2026 at 12:01 pm

    If I understand your question correctly, here’s the tip.

    1- Load data from DB and bind it to the combobox:

         Dim tableFormula as new DataTable("formula");
         using (Dim sqlConn as new SqlConnection("Server = localhost; Username= root; Password =; Database =forms"))
         {
            Dim sqlQuery  as string = "SELECT FormCode, FormName, FormDescription FROM formma;"
            Dim cmd as new SqlCommand(sqlQuery, sqlConn);
            Dim da  as new SqlDataAdapter(cmd); 
            //create dataTable and bind it with dataSet:
            da.Fill(tableFormula);
         }              
         //setting dataSource to comboBox:
         this.cmbCode.DataSource = new BindingSource(tableFormula, null);
    

    2- On SelectedIndex_Changed event handler of cmbCode combobox, set text based on selected item of the combobox.

            if(cmbCode.SelectedItem != null) 
            {
                txtName.Text = ((DataRow)cmbCode.SelectedItem)["FormName"].ToString();
                txtdesc.Text = ((DataRow)cmbCode.SelectedItem)["FormDescription"].ToString();
            }
    

    HTH.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Little help if you don't mind. Basically, I have 3 radio boxes and a
I have a small little tip calculator app that works pretty well, i am
little help guys im still a newbie at c++ error: invalid conversion from 'VboVO*
I recently needed to create speech bubbles. To create the little triangular tip at
Little Background: I have csv file which has lots of rows and each row
Little trouble in using css, in the below code, i have used odd and
A little help here to figure out what error to run this piece of
A little background: I have a perl script which is performing a number of
A little background: I am loading a WPF UI from a database which is
For the first time, I am asking a little bit of help over here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.