在文本框中输入值时,如何从SqlServer数据库表中检索数据. [英] How to Retieve the data from SqlServer Database Table when value entered in Textbox.

查看:108
本文介绍了在文本框中输入值时,如何从SqlServer数据库表中检索数据.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在文本框中输入值时,如何从SqlServer数据库表中提取数据.
================================================== ====

尊敬的朋友,

正在使用Asp.net,C#和SqlServer2005.

因此,在我的Sqlserver数据库表(UserPasswordsTable)中,我具有带有UserName,Password和Status的字段.
此数据库表中填充了用户名和密码,状态"列为空.

在我的Asp.net网页上,我有4个文本框和一个按钮.

这是我的设计.
=================

TxtCode TxtTrainNo SubmitBUTTON-TxtUserName,TxtPassword

所以我的要求是当用户输入TxtCode,TxtTrainNo并单击Submit按钮时.仅在单击Submit按钮时才必须填写其他两个文本框TxtUserName,Txt密码.

这些userName和Password必须从UsersPasswordsTable中填写到TxtUserName和TxtPassword TEXTBOXES中.

请帮忙,

解决方案

好,TxtCode,TxtTrainNo和用户名,密码之间有什么关系?这些字段之间有什么关系吗?如果是,则在提交按钮上单击数据库.将TxtCode和TxtTrainNo中的值作为参数传递给存储过程或查询.获取相关的用户名和密码,作为存储过程或查询的结果,并显示在表单中.


如果要通过数据库表中的ID检索值...
试试吧...

SqlDataAdapter da;
da =新的SqlDataAdapter(从login_tbl中选择*,其中user_name =""+ TextBox1.Text +"",初始目录= emp;数据源=.\\ sqlexpress;集成安全性= true);
ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();


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.

解决方案

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.


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();


这篇关于在文本框中输入值时,如何从SqlServer数据库表中检索数据.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆