How to execute "SQL Functions" in VB.Net

works on Access query but doesn't on VB.Net

Page 1 of 1

3 Replies - 19361 Views - Last Post: 26 September 2008 - 06:34 AM Rate Topic: -----

#1 vbnetskywalker  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 98
  • Joined: 08-June 08

How to execute "SQL Functions" in VB.Net

Posted 25 September 2008 - 08:22 AM

I'm trying to execute an SQL statement ,
if I make an Update query manually in Access , it works , this means that it's correct, but
if I try to execute it in VB.Net 2005 by an (OleDb.OleDbCommand) object , it doesn't work ,
it gives an error msg that is "Undefined function 'Replace' in expression."
-------------------------
this SQL statement's problem is that it contains the function ("Replace")
Dim Sql As String
Sql = "Update Names Set Name = Replace( ""vbnet_sky_walker"" , ""_"" , "" "" ) Where ID = 21"


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

to be more unexclusive , the question is gonna be :
How to execute "SQL Functions" in VB.Net

thanks in advance
vbnetskywalker

Is This A Good Question/Topic? 0
  • +

Replies To: How to execute "SQL Functions" in VB.Net

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,498
  • Joined: 29-May 08

Re: How to execute "SQL Functions" in VB.Net

Posted 25 September 2008 - 09:10 AM

Shouldn't it be?
Dim Sql As String
Sql = "Update Names Set Name = Replace( Name,""vbnet_sky_walker"" , ""_" ) Where ID = 21"


Was This Post Helpful? 0
  • +
  • -

#3 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,498
  • Joined: 29-May 08

Re: How to execute "SQL Functions" in VB.Net

Posted 25 September 2008 - 12:45 PM

Or
Dim Sql As String
Sql = "Update Names Set Name = ""_"") Where ID = 21 AND name=""vbnet_sky_walker"""


Was This Post Helpful? 0
  • +
  • -

#4 vbnetskywalker  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 98
  • Joined: 08-June 08

Re: How to execute "SQL Functions" in VB.Net

Posted 26 September 2008 - 06:34 AM

sorry sir , none of what you suggested helps me
any way ... this is not the way my code looks like ..... I just made this little sample to simulate it .......... so I put
Dim Sql As String  
Sql = "Update Names Set Name = Replace( ""vbnet_sky_walker"" , ""_"" , "" "" ) Where ID = 21"  



it's gonna store a constant value in the "Name" field
which is "vbnet sky walker" ........ because to the database it's gonna look like
Update Names Set Name = Replace( "vbnet_sky_walker" , "_" , " " ) Where ID = 21

-------------------
any way sir ..... I mentioned in my request that I tried that query in access and worked ..............

thanks for trying to help
any ideas to execute "SQL Function" ( Replace , Left , Right .......etc )

vbnetskywalker
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1