小编dju*_*c12的帖子

c#按ID搜索ms访问数据库

private void Filtriraj()
    {
        string filter = string.Empty;
        if (txtID.Text.Length > 0)
        {
            filter = "ID LIKE '%" + txtID.Text + "%'";
        }
        if (txtName.Text.Length > 0)
        {
            filter = "Name LIKE '%" + txtName.Text + "%'";
        }
    }
Run Code Online (Sandbox Code Playgroud)

我想在我的c#app中通过ms访问数据库表进行搜索.上面的一个连接到"Table1",它有一些字段,如ID,名称,姓氏,地址...... ID类型设置为自动编号,所有其他字段设置为文本.我能够搜索除ID以外的所有字段,这种方式上面不会工作,当我尝试按ID搜索时我得到异常(我在txtbox中输入一些在db中的ID号,exmp:'1')搜索txtName工作正常.

c# search ms-access

2
推荐指数
1
解决办法
1515
查看次数

标签 统计

c# ×1

ms-access ×1

search ×1