Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to populate textbox by database

How to populate textbox by database

Scheduled Pinned Locked Moved C#
helpdatabasetutoriallearning
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    scottichrosaviakosmos
    wrote on last edited by
    #1

    Hi all, I am a beginner and have many doubts.some of them sorted out but in some i m stuck.here is the one: i have a databse and a table in that. ex tbl1 with columns firstname and lastname. i have 2 textboxes on my form and want to populate those text boxes from the table. i tried one techniquie using datareader but it is showing the last data of the table. i want on formload the first row to be populated on the specific textboxes. secound problem is that i want to transfer the data in this form to another page as it is and populate controls of another form by value of this form controls.

    C 1 Reply Last reply
    0
    • S scottichrosaviakosmos

      Hi all, I am a beginner and have many doubts.some of them sorted out but in some i m stuck.here is the one: i have a databse and a table in that. ex tbl1 with columns firstname and lastname. i have 2 textboxes on my form and want to populate those text boxes from the table. i tried one techniquie using datareader but it is showing the last data of the table. i want on formload the first row to be populated on the specific textboxes. secound problem is that i want to transfer the data in this form to another page as it is and populate controls of another form by value of this form controls.

      C Offline
      C Offline
      Chetan Patel
      wrote on last edited by
      #2
      1. Use Top 1 Query while you are loading data from DataBase. Now you got the first row. 2) If you want to transfer the data from one form to another. Then if you are using MDI form then You can access All Control like Form1 obj=new Form1() Form2 obj2=new Form2() obj2.TextBox1.Text=obj.TextBox1.Text If you are opening form from another form then obj.TextBox1.Text=this.TextBox1.Text Still it is not resolved then post minimum code required to help you better.

      Best Regards, Chetan Patel

      M 1 Reply Last reply
      0
      • C Chetan Patel
        1. Use Top 1 Query while you are loading data from DataBase. Now you got the first row. 2) If you want to transfer the data from one form to another. Then if you are using MDI form then You can access All Control like Form1 obj=new Form1() Form2 obj2=new Form2() obj2.TextBox1.Text=obj.TextBox1.Text If you are opening form from another form then obj.TextBox1.Text=this.TextBox1.Text Still it is not resolved then post minimum code required to help you better.

        Best Regards, Chetan Patel

        M Offline
        M Offline
        Md Marufuzzaman
        wrote on last edited by
        #3

        I don't know why you suggest to use top 1 in the select sql statement...There are many ways to manage if your query return multiple rows.

        Thanks Md. Marufuzzaman


        I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups