SQL Stament executes directly in Access but not through my C# code

teixeira

Well-known member
Joined
Apr 5, 2005
Messages
94
Location
LEIRIA-PORTUGAL
Hi all,

I have a query to execute against an access database and is strange, because inside Access querys directly it executes perfectly, but inside my code its not executes, giving an error about the REPLACE keyword.The sql statement is the following:
SELECT CODIGO,CODBARRA FROM ARTIGOS WHERE REPLACE(CODIGO,.,)<>CODBARRA

Note: Im using Microsoft.Jet.OLEDB.4.0 as my Data Provider. with C# 2005

If anyone can help me about this, ill be very thankfull
Rgds
Tiago Teixeira
 
teixeira said:
Hi all,

I have a query to execute against an access database and is strange, because inside Access querys directly it executes perfectly, but inside my code its not executes, giving an error about the REPLACE keyword.The sql statement is the following:
SELECT CODIGO,CODBARRA FROM ARTIGOS WHERE REPLACE(CODIGO,.,)<>CODBARRA

Note: Im using Microsoft.Jet.OLEDB.4.0 as my Data Provider. with C# 2005

If anyone can help me about this, ill be very thankfull
Rgds
Tiago Teixeira
the replace function is deactivated by security configuration for applications outside of access. this can be overroiden via a registry setting, but this might not be suitable. for apps that call to the jet REPLACE I use a combination of instr and mid. its a pain I know, but its the only way to do it without changing the registry.

for a list of the safe jet functions look here and an outline of the configuration:
http://support.microsoft.com/default.aspx/kb/294698
 
Hi,

Thanks for your help, I used your suggestion and it is ok, but as you said it is more hard to code ( just a little) ;-).

And thanks for the link of the article, it give good informations.

Rgds
Tiago Teixeira
 
Back
Top