473,397 Members | 2,077 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,397 software developers and data experts.

Compiler hates Replace() function... any ideas?

Roy
Hey all,

Created an .aspx page using VB as the code behind. Compiler pops up
error: "BC30451: Name 'Replace' is not declared." Essentially, it acts
as if Replace is a custom function that needs to be declared, not a
built in one. What gives? FWIW, the code below occurs within a sub
within a class. Thanks for any advice!
strSQLQuery = "UPDATE [lla] " _
& "SET assigned_to = N'" & Replace(assigned_to.Text, "'", "''") & "', "
_
& "assigned_dt = '" & Replace(assigned_dt.Text, "'", "''") & "', " _
& "poe_recon_done = '" & Replace(poe_recon_done.Text, "'", "''") & "',
" _
& "vdn_done = '" & Replace(vdn_done.Text, "'", "''") & "', " _
& "vdn_done_dt = '" & Replace(vdn_done_dt.Text, "'", "''") & "', " _
& "final_appvl = '" & Replace(final_appvl.Text, "'", "''") & "', " _
& "final_appvl_dt = '" & Replace(final_appvl_dt.Text, "'", "''") & "',
" _
& "carrier_web_validation = '" & Replace(carrier_wv.Text, "'", "''") &
"', " _
& "notes = N'" & Replace(notes.Text, "'", "''") & "' " _
& "WHERE ISNULL(voydoc,'') + ISNULL(poe,'') + ISNULL(pod,'') = " &
strID & ";"
BTW, my imports are:
imports System
imports System.Data
imports System.Data.SqlClient
imports System.Web
imports System.Web.UI
imports System.Web.UI.WebControls
imports System.Web.UI.HtmlControls

Nov 21 '05 #1
4 2195
Imports Microsoft.VisualBasic?

"Roy" <ro**********@gmail.com> schreef in bericht
news:11**********************@c13g2000cwb.googlegr oups.com...
Hey all,

Created an .aspx page using VB as the code behind. Compiler pops up
error: "BC30451: Name 'Replace' is not declared." Essentially, it acts
as if Replace is a custom function that needs to be declared, not a
built in one. What gives? FWIW, the code below occurs within a sub
within a class. Thanks for any advice!
strSQLQuery = "UPDATE [lla] " _
& "SET assigned_to = N'" & Replace(assigned_to.Text, "'", "''") & "', "
_
& "assigned_dt = '" & Replace(assigned_dt.Text, "'", "''") & "', " _
& "poe_recon_done = '" & Replace(poe_recon_done.Text, "'", "''") & "',
" _
& "vdn_done = '" & Replace(vdn_done.Text, "'", "''") & "', " _
& "vdn_done_dt = '" & Replace(vdn_done_dt.Text, "'", "''") & "', " _
& "final_appvl = '" & Replace(final_appvl.Text, "'", "''") & "', " _
& "final_appvl_dt = '" & Replace(final_appvl_dt.Text, "'", "''") & "',
" _
& "carrier_web_validation = '" & Replace(carrier_wv.Text, "'", "''") &
"', " _
& "notes = N'" & Replace(notes.Text, "'", "''") & "' " _
& "WHERE ISNULL(voydoc,'') + ISNULL(poe,'') + ISNULL(pod,'') = " &
strID & ";"
BTW, my imports are:
imports System
imports System.Data
imports System.Data.SqlClient
imports System.Web
imports System.Web.UI
imports System.Web.UI.WebControls
imports System.Web.UI.HtmlControls

Nov 21 '05 #2
Roy
doh!!

Yeah, that was it. Thanks Qwert!

Nov 21 '05 #3

"Roy" <ro**********@gmail.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
Created an .aspx page using VB as the code behind. Compiler pops up
error: "BC30451: Name 'Replace' is not declared." .. . . & "SET assigned_to = N'" & Replace(assigned_to.Text, "'", "''") & "', "

.. . .

Strings are far cleverer than they used to be - take a look at the methods
on the String Class :

.. . .
& "SET assigned_to = N'" & assigned_to.Text.Replace("'", "''") & "', "
.. . .

HTH,
Phill W.
Nov 21 '05 #4
Though there's a neater way you can do this now using String.Format and a
utility function

Function Quote(Byval val As String) As String
Return val.Replace("'", "''")
End Function

' NB Shorted update statement for clarity
strSQLQuery = "UPDATE [lla] SET assigned_to = N'{0}', assigned_dt = '{1}'
strSQLQuery = String.Format(strSQLQuery, Quote(assigned_to.Text),
Quote(assigned_dt.Text))

The other way would be to use a SqlCommand and parameters, that way you
don't have to handle the string quoting and is even more robust against SQL
injection attacks.

Regards

Paul
Nov 21 '05 #5

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

Similar topics

34
by: Nikola Skoric | last post by:
Is the a PHP compiler? A program that compiles PHP code to executable which doesn't need php interpreter to execute... -- Pozdrav/Regards, Nikola Skoric. "...Usne, tice-rugalice - a u oku...
12
by: Barnes | last post by:
Does anyone know of a good way to use the JavaScript string.replace() method in an ASP form? Here is the scenario: I have a form that cannot accept apostrophes. I want to use the replace() so...
2
by: James Marshall | last post by:
I'm trying to override location.replace() but I can't. I can override window.open(), document.write(), and other built-in methods, but not location.replace(). Here's a demo that overrides two...
13
by: Bryan Parkoff | last post by:
You may notice that switch (...) is much faster than function that can gain a big improved performance because it only use JMP instruction however function is required to use CALL, PUSH, and POP...
7
by: Paul Sheer | last post by:
I need to automatically search and replace all fixed size buffer strcpy's with strncpy's (or better yet, strlcpy's) as a security and stability audit. The code base is large and it is not feasable...
3
by: CK | last post by:
Hi Guys, I need a function that will replace the letter after a "hyphen" with a capital letter. Like if the user enter "Zeta-jones" it would be "Zeta-Jones". I am a little stumped. Any ideas? I...
13
by: CK | last post by:
Hi all, I have a textarea control. I am putting it's value in an html email. The problem is that the new lines are being ignored. I want to take the controls value and replace any newline...
0
by: WebDev2 | last post by:
I can't get AJAX.NET Pro to work. I keep getting a Compiler Error Message: CS0246: The type or namespace name 'AjaxPro' could not be found (are you missing a using directive or an assembly...
159
by: bernard | last post by:
howdy! please recommend a good c compiler. - should be small - should be fast - should come with a good ide - should be inexpensive i am using windows os.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.