-1

私はプロジェクトに取り組んでおり、特定のテキストまたはキーワードを使用して 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();
    }
}

}

4

1 に答える 1