c#.net:retriving data from db to textboxes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vijaysri
    New Member
    • Apr 2010
    • 1

    c#.net:retriving data from db to textboxes

    can anyone help me,i have placed 2textboxes and a button,one textbox is to give the name ,textbox2 is to retrive values from db(address of a paricular name ),i tried a lot ,but i couldn't make it,help pleaz.......... ........
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    Could you please post the relevant code here.
    And please use code tags while posting your code.

    Regards
    Dheeraj Joshi

    Comment

    • tlhintoq
      Recognized Expert Specialist
      • Mar 2008
      • 3532

      #3
      I'm sure you understand that to put text in a textbox you just set the textbox.text property.

      So I assume the real crux of the problem is in working with a database, right?
      Database tutorial Part 1
      Database tutorial Part 2

      Comment

      • stoogots2
        New Member
        • Sep 2007
        • 77

        #4
        I don't understand what your table looks like. If you are running 3 queries, each returning 1 value which you want to use as the value of your textbox, use ExecuteScalar method of the SqlCommand object.
        and then set your values for your textboxes like this:

        TextBox2.Text = (string)YourSql CommandObject.E xecuteScalar();

        otherwise you will set TextBox.Text equal to whatever construct you have populated from the database (Datatable, array, etcetera).

        Comment

        Working...