auto populate this textbox using vb.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kalboako1987
    New Member
    • Nov 2007
    • 1

    auto populate this textbox using vb.net

    hello guys

    Im trying to autopopulate my form from a table in my database called Enrollment.it will fill the textboxes in my form whenever the id number typed in the textbox is existing in my database.. the selection will be based in the highest EnrollmentID whatever is the highest EnrollmentID that matches with id number will automatically fill the textboxes. i put these code inside my idnumber textbox by double clicking it. can somebody help me please...


    i need all the advice that you can give me..

    [code=vb]

    Private Sub populate()
    Dim xx As DataTable


    xx = db1.doQuery("se lect idno from Enrollment where idno='" + Me.txtidno.Text + "'")
    If xx.Rows.Count <> 0 Then

    xx = db1.doQuery("se lect Firstname, Middlename, Lastname, level1, preschoollevel, primarylevel,se condarylevel,tu itionfee, amountpaid,tobw ithd,tobwithout d from Enrollment where Firstname='" + Me.txtfirstname .Text + "', Middlename='" + Me.txtmi.Text + "', Lastname='" + Me.txtlastname. Text + "', level1 = '" + Me.ComboBox1.Te xt + "', preschoollevel= '" + Me.cmbpreschool .Text + "', primarylevel='" + Me.cmbprimary.T ext + "', secondarylevel ='" + Me.cmbsecondary .Text + "', tuitionfee='" + Me.TextBox5.Tex t + "', amountpaid ='" + Me.txtpreviousa mountpaid.Text + "', tobwithd= '" + Me.txtbal.Text + "', tobwithoutd = '" + Me.txtbal.Text + "'")[/code]
    Last edited by pbmods; Nov 15 '07, 04:59 AM. Reason: Added CODE tags, merged duplicate threads.
  • Shashi Sadasivan
    Recognized Expert Top Contributor
    • Aug 2007
    • 1435

    #2
    Do you want to populate a datagridview?
    or details view?

    In Short, how do you want your data to be shown on the form?
    You just cant put it there, can you?

    Comment

    • Jugmike
      New Member
      • Mar 2007
      • 4

      #3
      Do you want to autopopulate only the textboxes as seen in your code then you just need to call the event automatically every time the id is entered by using the onblur event of the ID textbox.

      Comment

      • Shashi Sadasivan
        Recognized Expert Top Contributor
        • Aug 2007
        • 1435

        #4
        and change the comma in the sql string to AND

        sql syntax is usually
        [CODE=sql]Select * from tableName where field1 = value1 and field2 = value2[/CODE]
        and not
        [CODE=sql]Select * from tableName where field1 = value1 ,field2 = value2[/CODE]

        Comment

        • debasisdas
          Recognized Expert Expert
          • Dec 2006
          • 8119

          #5
          You need to populate the data in the textbox from database.

          Comment

          • Shashi Sadasivan
            Recognized Expert Top Contributor
            • Aug 2007
            • 1435

            #6
            are you using any sort of typed datasets?
            in that case drag the fields from the data source view to your form.

            and you would not have to do anything else

            only if this is in windows forms

            Comment

            Working...