How to populate textbox by database
-
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.
-
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.
- 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
-
- 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
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.