How the condition works incorrectly

C # window forms: → Database: access

I made a request similar to this

Select * from Emp where E_Name Like 'Alok*??????' 

the above query is for retrieving records that have Alok and 6 charachter .

If I execute this request on access, it works fine and retrieves the record, but when I try to use it in C #

 Select * from Emp where E_Name Like 'Alok*??????' 

or

 Select * from Emp where E_Name Like 'Alok%??????' 

Both of them do not work, and I also tried using both types of connection strings

 Microsoft.ACE.OLEDB.12.0; 

AND

 Microsoft.Jet.OLEDB.4.0; 

How to solve this problem?

+5
source share
1 answer

You have this request that works in an access session ...

 Select * from Emp where E_Name Like 'Alok*??????' 

If you need a similar request that you run from external Access using OleDb, change the wild card symbols ...

 Select * from Emp where E_Name Like 'Alok%______' 

But if you really want only Alok accompanied by exactly 6 characters, use this instead ...

 Select * from Emp where E_Name Like 'Alok______' 
+4
source

Source: https://habr.com/ru/post/1202501/


All Articles