LIKE query on an Access database via C# always returns COUNT(*) of 0

后端 未结 2 620
粉色の甜心
粉色の甜心 2021-01-15 03:39

Please look into following code:

using (OleDbConnection openCon = new OleDbConnection(ConfigurationManager.AppSettings[\"AccessConnectioString\"]))
{
                


        
2条回答
  •  有刺的猬
    2021-01-15 04:01

    You are getting tripped up by the difference in LIKE wildcard characters between queries run in Access itself and queries run from an external application.

    When running a query from within Access itself you need to use the asterisk as the wildcard character: LIKE 'RT*'.

    When running a query from an external application (like your C# app) you need to use the percent sign as the wildcard character: LIKE 'RT%'.

提交回复
热议问题