我知道这个问题已经被问了很多次关于如何创建一个搜索按钮。我对C#编程非常陌生,我很难创建一个搜索,只是没有找到我从其他职位寻找的东西。所以我希望有人能帮助我。C#中的搜索按钮#
我创建了一个Windows窗体应用程序,并使用DataSet中的“Details”视图进行表单设置,并且当我从记录滚动到记录时,数据在应用程序中正确显示。我的数据存储在一个sdf文件中。我想让人们输入一个“账号”或一个人的“姓氏”,然后能够点击搜索按钮。在搜索按钮之后,预先安排的字段将随信息更新。为了能够选择“姓氏”或“帐号”,我可以根据需要在组合框中列出项目。
我已经包含了代码的一些副本,一些项目的命名已被更改为不透露我的职业。任何帮助是极大的赞赏。
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void custtableBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.custtableBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.custDataSet);
}
private void label1_Click(object sender, EventArgs e)
{
}
private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
{
}
private void custtableBindingNavigatorSaveItem_Click_1(object sender, EventArgs e)
{
this.Validate();
this.custtableBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.custDataSet);
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'custDataSet.custtable' table. You can move, or remove it, as needed.
this.custtableTableAdapter.Fill(this.custDataSet.custtable);
}
private void file_Name_12TextBox_TextChanged(object sender, EventArgs e)
{
}
private void fillByToolStripButton_Click(object sender, EventArgs e)
{
try
{
this.custtableTableAdapter.FillBy(this.custDataSet.custtable);
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
private void btnfind_Click(object sender, EventArgs e)
{
}
}
}
目前在两个表格之间大约有15k条记录,搜索将集中在两个表格中的一个。信息将存储在网络驱动器中,并且多个用户将访问数据。我为一家主要的有线电视提供商 – Dan
确定,你说你正在使用SDF文件。我不太熟悉SQL Server CE的功能,但我建议您使用上面的选项1。您需要决定是否要在读取它们并将它们写回或允许未提交的读取等之间锁定记录,正如您所说,您将拥有多个用户。你的问题与搜索有关,而不是SQL/SPROC,所以我通常会说你需要SPOCS,你可以用你的表单的输入调用并返回数据。 SPROC将只使用Where子句。 – Wolf5370
沃尔夫你能否提供一份代码的样子,在编程方面,我很宝贝,所以我不知道它应该如何写出来。 – Dan