AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 Getting the value into a textbox from database
Posted by sujany on  4/15/2009 9:41:05 PM Category: ADO.NET
Add to my favorites
Email to friend
Hello,

Its a SQL Server database with table name AddressDetails--with columns AddressID,Zipcode,Phone No etc.

by entering the AddressID value in the textbox, it should read the PhoneNo value from the database and is to be display in textbox provided.


Could any one please help me to solve the problem.

Thanks in advance



Post Your Reply Post New Question

 Viewer's Reply
Use OnTextChanged Event
Answered By Moderator1 on 4/18/2009 10:03:41 AM
hi,

You can write code in the OnTextChanged Event.

Query:
Select * from AddressDetails Where AddressID = txtAddressId.Text;

Execute the query in a SqlDataAdapter and the result in a datatable, then you can use the value in the datatable as follows,

txtPhoneNo.Text = dt.Rows[0]["PhoneNo"].ToString();
 
Post Your Reply If you still have problem, post it again under this reply for better response.

 
Sponsored by
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Easing the Migration to Microsoft SQL Server 2005
The ASP.NET 2.0 Anthology: 101 Essential Tips, Tricks & Hacks - Free 156 Page Preview