Click here to Skip to main content
15,891,906 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
How to Retieve the data from SqlServer Database Table when value entered in Textbox.
======================================================

Dear Friends,

am working on Asp.net , C# , SqlServer 2005.

so, In my Sqlserver Database table(UserPasswordsTable) I have fields with UserName,Password and Status.
This Database Table is Filled with UserName and Password and the Status column is Empty.

on my Asp.net webpage I have 4 Textboxes and a button.

This is my Design.
=================

TxtCode TxtTrainNo SubmitBUTTON - TxtUserName, TxtPassword

so my requirement is when the user enters TxtCode , TxtTrainNo and Clicks on Submit button The Other Two Textboxes TxtUserName , Txt Password Must be Filled only when Submit button clicks.

These userName and Password Must be filled from UsersPasswordsTable into TxtUserName and TxtPassword TEXTBOXES.

Please help,

Thanks in ADVANCE.
Posted
Comments
So, what is the problem you are facing while implementating your requirement ?

Ok, How TxtCode, TxtTrainNo and Username, Password are related? Is there any relation between these fields? If yes, then hit the database on submit button click. Pass the values in TxtCode and TxtTrainNo as parameters to the stored procedure or query. Get the related Username and Password as the result of stored procedure or query and display to the form.
 
Share this answer
 
if we want to retrieve value by id in database table ...
Try it...

SqlDataAdapter da;
da = new SqlDataAdapter("select * from login_tbl where user_name='"+TextBox1.Text+"'", initial catalog=emp;data source=.\\sqlexpress;integrated security=true);
ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900