如何在文本框中显示搜索结果? [英] How Can I Show Up A Search Result In A Textbox?
问题描述
我已经创建了一个表格代码,想要在文本框imei中搜索和检索设备Imei的答案,当我点击搜索时,想要显示文本框代码中的结果(code_mck)我希望显示结果
I’ve created a table Code and would like to search and retrieve an answer introducing device Imei in textbox imei und when I click on the search want display the result(code_mck)in textbox code i want display the result
id Imei code_mck
1 356885021519453 830782136
2 356885021519156 948790617
3 356885021518893 715398945
4 356885021518935 567456626
5 359654022104377 557960750
最初我是典型的三层架构,搜索方法在数据层中我的SQL查询有些麻烦
Initially I’ve typical three layer architecture and the search method is in the Data Layer I have some trouble with my SQL Query
public DataSet recherche(string code)
{
DataSet ds = null;
using (OleDbConnection cnn = new OleDbConnection(strConn))
{
cnn.Open();
string Oledb = "SELECT * FROM Code WHERE Imei=@IMEI";
using (OleDbDataAdapter adapter = new OleDbDataAdapter(Oledb, cnn))
{
adapter.SelectCommand.Parameters.AddWithValue("@IMEI", code);
ds = new DataSet();
adapter.Fill(ds, "Code");
}
}
return ds;
}
B usiness逻辑层中的
in the Business Logic layer
namespace unlock2_buisness
{
public class code_imei
public DataSet rechercheduCode(string imei)
{
unlockDAL objetDataLayer = new unlockDAL();
if (imei == "")
throw new Exception("merci d'indique l'imei de recherche");
DataSet dt = null;
dt = objetDataLayer.recherche(imei);
return dt;
}
专用于搜索的文本框在文本框代码中显示结果没有响应而且不是通过提供设备IMEI来获取适当的代码,因为它应该来自表格。
in my User Layer the text box dedicated for search to display the result in textbox code is not responding and am not getting the appropriate code by providing the device IMEI as it should be from the table.
private void btnrechercheimei_Click(object sender, EventArgs e)
{
imeiLogic.rechercheduCode(txtimei.Text);
imeiLogic.rechercheduCode(txtcode.Text);
}
我将非常感谢您的支持。干杯。
I will appreciate your support. Cheers.
推荐答案
尝试类似
Try something like
private void btnrechercheimei_Click(object sender, EventArgs e)
{
DataSet ds= new DataSet;
ds=imeiLogic.rechercheduCode(txtimei.Text);
if (ds.Tables[0].Rows.Count>0)
{
this.txtcode.Text=ds.tables[0].Rows[0]["code_mck"].ToString();
}
}
这篇关于如何在文本框中显示搜索结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!