【发布时间】:2020-04-10 13:05:43
【问题描述】:
我正在做一个项目,我必须在该项目中执行一项任务,我必须通过特定文本或关键字从 MS Access 数据库 2016 文件中打印/查找数据我会尝试一切但无法解决我的问题所以在尝试了一切之后我决定在这里发布我的问题以获得一些帮助来解决它。 我附上了我的代码,您可以看到,但该代码没有执行任何操作,并且在尝试搜索错误时出现错误
“System.FormatException”类型的第一次机会异常发生在 mscorlib.dll 中 附加信息:输入字符串的格式不正确。 如果有这个异常的处理程序,程序可以安全地继续。
这是我在执行任务时遇到的错误。
namespace Vechile_Registration_System
{
public partial class Verification : Form
{
public Verification()
{
InitializeComponent();
}
private void Verification_Load(object sender, EventArgs e)
{
}
private void btnsearch_Click(object sender, EventArgs e)
{
searchDataBase();
}
private void searchDataBase()
{
string strsearch = txtsearch.Text.Trim().ToString();
StringBuilder sb = new StringBuilder();
vehicleBindingSource.Filter = string.Format("[Registration No] LIKE '%{0}%'", strsearch);
string strFilter = sb.ToString();
vehicleBindingSource.Filter = strFilter;
if (vehicleBindingSource.Count != 0)
{
dataGridView1.DataSource = vehicleBindingSource;
}
else
{
MessageBox.Show("No Records Found. \n The Vehcile may not register or you have enter wrong Registration Number.");
}
}
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
Form1 MMenu = new Form1();
MMenu.ShowDialog();
}
}
}
【问题讨论】:
-
评论不用于扩展讨论;这个对话是moved to chat。
标签: c# database visual-studio ms-access-2016 icsharpcode