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 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
doh!!
Yeah, that was it. Thanks Qwert!
"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.
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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.
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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...
|
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...
|
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: 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...
| |