Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Embarrassing simple..but I'm stumped

Status
Not open for further replies.

dmjarby

Technical User
Jan 10, 2004
46
CA
I'm using OleDbCommand to update records in an Access table as follows:

update Table1 set Field2=Replace(Field1,'value','newvalue')

This works in Access directly using a query but in ASP.NET, I get the error:

Undefined function 'Replace' in expression
 
You should do the Replace command first and pass the correct SQL statement to the OleDbCommand.

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Can't I just have a SQL statement do the replace dynamically without iterating though the rows individually in my code? (the statement works in an MS Access query)
 
The OleDbCommand is not database specific so it doesn't know that the Microsoft Access Replace function exists which is why it works in the database itself but not from your page.

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Thanks ca8msm, is there an OleDBCommand that I could use instead to achieve the same results?
 
You can call other access queries using the "execute Query1" for your command object. Unfortionately the replace function causes an error. I don't see any work around for this other than using the old ADODB with a wrapper.
 
An alternative method would be to use the Microsoft Access Object Library and execute the query from within the file itself (but I'm not sure what speed implications this would have so you would have to try it out).

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top