473,394 Members | 1,697 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

C# - MS Access SQL using OleDbCommand

D2
Hi All,

I am trying to run the following query from OleDbCommand object but
getting an exception.
UPDATE [Files] SET FilePath = REPLACE(FilePath, 'd:\\', 'c:\\')

Exception is:
Undefined function 'REPLACE' in expression.

Above query executes fine from within access but throws exception when
used from code.

I understand that the Replace() method is available from access but
not from oledb. I'm just wondering what is the best approach to
achieve the same results(as given by above query) from code?
Cheers!
d2

May 5 '07 #1
2 6694
D2,

You could retrieve all the rows that have a FilePath containing "d:\\" into
a datatable, make the necessary changes and then update the database.

Kerry Moorman
"D2" wrote:
Hi All,

I am trying to run the following query from OleDbCommand object but
getting an exception.
UPDATE [Files] SET FilePath = REPLACE(FilePath, 'd:\\', 'c:\\')

Exception is:
Undefined function 'REPLACE' in expression.

Above query executes fine from within access but throws exception when
used from code.

I understand that the Replace() method is available from access but
not from oledb. I'm just wondering what is the best approach to
achieve the same results(as given by above query) from code?
Cheers!
d2

May 5 '07 #2
D2
On May 5, 8:57 pm, Kerry Moorman
<KerryMoor...@discussions.microsoft.comwrote:
D2,

You could retrieve all the rows that have a FilePath containing "d:\\" into
a datatable, make the necessary changes and then update the database.

Kerry Moorman

"D2" wrote:
Hi All,
I am trying to run the following query from OleDbCommand object but
getting an exception.
UPDATE [Files] SET FilePath = REPLACE(FilePath, 'd:\\', 'c:\\')
Exception is:
Undefined function 'REPLACE' in expression.
Above query executes fine from within access but throws exception when
used from code.
I understand that the Replace() method is available from access but
not from oledb. I'm just wondering what is the best approach to
achieve the same results(as given by above query) from code?
Cheers!
d2
hmmm.. but thats a very long procedure.. i believe database will
handle the query better than me writing code to do this. Anyways, i hv
got the solution in a different thread. we can use Mid() method but
not substr, instr etc.

Cheers!
D2

May 7 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: David | last post by:
Hi everyone. I have read every page that Google returns on this topic, but can't find anything that resolves my problem. Basically, I have an Access Database that does a number of different...
1
by: Abareblue | last post by:
I have no clue on how to insert a record into access. here is the whole thing using System; using System.Drawing; using System.Collections; using System.ComponentModel;
7
by: Luminal | last post by:
Greetings I'm having some problems on my C# application. I'm using an access database and I'm not able to do select queries with the ' character. My code is this: // some previous code like...
14
by: Roy Gourgi | last post by:
Hi, I need to store and retrieve information from a database. It looks as though there is a lot more support for SQLServer than there is for Access, correct me if I am wrong. What do I have...
3
by: dale zhang | last post by:
Hi, I am trying to read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp The article author is using PictureBox for windows...
1
by: Kevin | last post by:
Hello experts, I'm a newbee to ASP.NET. And I have been struggling solving this problem. But I can't do it. Can you please help me get over this wall? Below is the code and error message: <%@...
1
by: Harry Devine | last post by:
I have a DataGrid that is configured to use the Edit/Update/Cancel concept correctly. My grid shows values from 5 database fields. I only need to update that last 4 fields. The last field is a...
0
by: yukijocelyn | last post by:
I have experienced a problem here while doing a form for accessing datadbase using MS Access. I'm using the AccessDataSource control, and using Gridview to pull the data from the database. I am able...
4
ollyb303
by: ollyb303 | last post by:
Hi, wasn't sure whether I should post this under .net, IIS or access, but I've plumped for .net! I have a problem with an asp.net website which I am hosting on a windows server 2003 under IIS...
4
by: sarabonn | last post by:
hallo everyone, Iam using access database and visual c# 2008. Iam tried to insert data into table with lot of method but nothing works, i dont know what is wrong. here...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.