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工作正常.