473,698 Members | 2,923 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(assigne d_to.Text, "'", "''") & "', "
_
& "assigned_d t = '" & Replace(assigne d_dt.Text, "'", "''") & "', " _
& "poe_recon_ done = '" & Replace(poe_rec on_done.Text, "'", "''") & "',
" _
& "vdn_done = '" & Replace(vdn_don e.Text, "'", "''") & "', " _
& "vdn_done_d t = '" & Replace(vdn_don e_dt.Text, "'", "''") & "', " _
& "final_appv l = '" & Replace(final_a ppvl.Text, "'", "''") & "', " _
& "final_appv l_dt = '" & Replace(final_a ppvl_dt.Text, "'", "''") & "',
" _
& "carrier_web_va lidation = '" & Replace(carrier _wv.Text, "'", "''") &
"', " _
& "notes = N'" & Replace(notes.T ext, "'", "''") & "' " _
& "WHERE ISNULL(voydoc,' ') + ISNULL(poe,'') + ISNULL(pod,'') = " &
strID & ";"
BTW, my imports are:
imports System
imports System.Data
imports System.Data.Sql Client
imports System.Web
imports System.Web.UI
imports System.Web.UI.W ebControls
imports System.Web.UI.H tmlControls

Nov 21 '05 #1
4 2209
Imports Microsoft.Visua lBasic?

"Roy" <ro**********@g mail.com> schreef in bericht
news:11******** **************@ c13g2000cwb.goo glegroups.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(assigne d_to.Text, "'", "''") & "', "
_
& "assigned_d t = '" & Replace(assigne d_dt.Text, "'", "''") & "', " _
& "poe_recon_ done = '" & Replace(poe_rec on_done.Text, "'", "''") & "',
" _
& "vdn_done = '" & Replace(vdn_don e.Text, "'", "''") & "', " _
& "vdn_done_d t = '" & Replace(vdn_don e_dt.Text, "'", "''") & "', " _
& "final_appv l = '" & Replace(final_a ppvl.Text, "'", "''") & "', " _
& "final_appv l_dt = '" & Replace(final_a ppvl_dt.Text, "'", "''") & "',
" _
& "carrier_web_va lidation = '" & Replace(carrier _wv.Text, "'", "''") &
"', " _
& "notes = N'" & Replace(notes.T ext, "'", "''") & "' " _
& "WHERE ISNULL(voydoc,' ') + ISNULL(poe,'') + ISNULL(pod,'') = " &
strID & ";"
BTW, my imports are:
imports System
imports System.Data
imports System.Data.Sql Client
imports System.Web
imports System.Web.UI
imports System.Web.UI.W ebControls
imports System.Web.UI.H tmlControls

Nov 21 '05 #2
Roy
doh!!

Yeah, that was it. Thanks Qwert!

Nov 21 '05 #3

"Roy" <ro**********@g mail.com> wrote in message
news:11******** **************@ c13g2000cwb.goo glegroups.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(assigne d_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.Tex t.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(s trSQLQuery, 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
3684
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 tajac Da sam kaput sa dva lica, da sam Gospo'n Propalica..." http://newusers.cjb.net/ - site o Usenetu na hrvatskom!
12
8157
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 that the apostrophe is automatically replace with two '' . Reason being--SQL Server does not like apostrophes being sent to database. I've tried to do this on the server side in the SQL area of the ASP page by writing a function (with some great...
2
3614
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 built-in methods, then reports on them: location.replace= function (url) { alert(url) } ; alert('location.replace=\n'+location.replace) ; document.write= function (html) { alert(html) } ; alert('document.write=\n'+document.write) ;
13
2575
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 instruction that can be slower. I created three functions in an array. Array is called pArray_Func(). pArray_Func() contains three functions. "xx" can be used to point each function. Let say, I have over 1,000 functions. I would put "inline"...
7
3342
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 to manually perform these changes. I would like perhaps a C++ parser that can automatically detect use of a strcpy to a buffer of fixed size. For instance, struct x { char member;
3
2124
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 know it's a combination of substring and replace and toUpper(). I just can't get the method call correctly. I use iHyphen = x.indexOf("-");
13
18403
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 carriage returns, with an html <br> tag. I tried the following function but it doesn't work. Does anyone have any ideas how to accomplish this? Thanks in advance. ~ CK string getComments()
0
3260
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 reference?) I have a reference to AJAX.NET Pro and I created and the wire up was placed in the Webconfig file. <!-- Wire up Ajax.NET Pro ashx Handler --> <location path="ajaxpro">
159
7065
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
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9170
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8873
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7740
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.