Problem pulling information from combobox to textbox

Results 1 to 2 of 2
  1. #1
    Novice XerTroV is offline
    MemberRank
    Apr 2022 Join Date
    3Posts

    Problem pulling information from combobox to textbox

    Good morning, I'm having problems when trying to send information to textbox, using the combobox selection presents the error:



    Code:
                If Drs.Lenght > 0 Then
                    Drs = Dt.Select("mail_addr=" + comboBox1.SelectedValue.ToString())
                    textBox2.Text = Drs(0)("mail_addr")
                End If
    The intention is to pull information from email sql for example and print it in a textbox, from the account selection in the combobox
    Asking to send it directly to a combobox, he sends it normally

    How could I solve this problem please?
    Last edited by XerTroV; 15-04-22 at 01:01 PM.


  2. #2
    C++ Developer zipper20032 is online now
    MemberRank
    Oct 2006 Join Date
    0x198837ADLocation
    665Posts

    Re: Problem pulling information from combobox to textbox

    DataRow object doesn't have a Length method.

    You can check every element or a specific element from that DataRow if it's null by looping through your DataRows or from your DataTable directly

    Code:
    If Dt.Rows.Count > 0 Then //Check the Rows count > 0 from DataTable
        Drs = Dt.Select("memb___id=" + comboBox1.Text) // SELECT * FROM YOUR DATATABLE WHERE memb___id = comboBox1.Text (DataTable querying)
        textBox2.Text = Drs["mail_addr"].ToString() // Not sure here but should work
    End If
    
    (I don't know VB.NET (Wannabe C# programming language) so it's hard to help you out, but I'll try)
    DataRow are a single row from a DataTable. You need to specify what DataRow from DataTable you want to select first tho.

    Suggestion and advice: Name your GUI objects according to their scope and usage because if you need some help in your code, no one wants to spend their time just trying to puzzle up every comboBox1, comboBox2, textBox1, textBox2, etc and we can see more easily what are you actually trying to do. Sometimes can be just a wrong object used from your code. (comboBox2 instead of comboBox1, etc...)

    E.g.:
    If you need a comboBox for Email: name it emailComboBox, etc.
    If you need a textBox for entering a value for attributes: name it strengthTextBox, dexterityTextBox, etc.

    Proper naming saves time!
    Last edited by zipper20032; 15-04-22 at 03:52 PM.



Advertisement