使用文本框和按钮搜索 [英] Searching with textbox and a button

查看:77
本文介绍了使用文本框和按钮搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了很多有关处理数据库的教程,但仍然不知道如何做.我的主要问题是我想使用文本框和按钮来搜索数据库,然后在新表单的文本框中显示结果.顺便说一句,我正在使用visualstudio2010(c#).对不起,英语不好.

例如:

searchform:搜索ID:(这是一个文本框)//输入学生ID进行搜索


resultform:搜索ID:200489//在texboxes中显示结果


提前非常感谢您.任何帮助将不胜感激.

I''ve been reading lots of tutorial about handling database but still dont how to do it. My main problem is that i want to use a textbox and a button to search my database and then displays results in a new form''s textboxes. By the way i''m using visualstudio2010(c#). sorry for the bad english.

ex:

searchform: search ID: (this is a textbox) //Enters student ID to search


resultform: search ID: 200489 // displays result in texboxes


thank you so much in advance. any help would be greatly appreciated.

推荐答案

嗨ram,

通过这样的查询

您通过
获取的记录
从table_name中选择*,其中searchid =''"+ txtsearchid.text +"'';
hi ram,

pass query like this

your getting records through

select * from table_name where searchid=''"+txtsearchid.text+"'';


你好ramcab,

您可以在文本框中输入ID后,在按钮单击事件中搜索记录.并将结果存储在会话或查询字符串中以传递给另一种形式.并在该表格的texbox中设置该值.
oke:
hello ramcab,

you can search your record on button click event after enter the id in textbox. and store the result in session or query string to pass to another form. and set that value in texbox of that form.
loke :
Session["name_of_student"]=abc; /* abc is string that contains your data like name of student. */


使用Response.Redirect()或您想用来打开新表单的任何内容.
并设置如下值:


use Response.Redirect() or what ever you wanna use to open new form.
and set value like :

txtbox.Text=Session["name_of_student"].ToString();


希望对您有帮助.
如果有帮助,请不要忘记将其标记为答案. :)


Hope this will help you.
Don''t forget to mark as answer if it helps. :)


您可以像这样使用查询
从tblstudent中选择*,其中searchId =''" + txtid.text +''
像这样
You Can Use Query Like this
Select * from tblstudent where searchId=''"+txtid.text+"''
like this


这篇关于使用文本框和按钮搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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