473,385 Members | 1,622 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,385 software developers and data experts.

Replace function

Hi,

I am tryng to use replace and it is not working. i'm surprised as it
would seem to be a simple method. My code:

foreach (DataRow row in dsSched.Tables["Schedule"].Rows)
{
if (_bStopWork) break;
lsTemp = String.Empty;
lsTemp = row["UpdateSQL"].ToString() +
System.Environment.NewLine;
lsTemp.Replace("S","?");
sb.Append(lsTemp);
}

I am retrieving rows from a dataset to string and the replace is not
replacing the 'S''s like a assume they should.

Any ideas? Thanks!

Nov 5 '07 #1
4 2574
Try:

sb.Append (lsTemp.Replace ("S", "?");

Alternatively, to correct your code above you need to change the line to:
lsTemp = lsTemp.Replace ("S", "?")

Hilton
"Soulless" <dg*******@gmail.comwrote in message
news:11*********************@i13g2000prf.googlegro ups.com...
Hi,

I am tryng to use replace and it is not working. i'm surprised as it
would seem to be a simple method. My code:

foreach (DataRow row in dsSched.Tables["Schedule"].Rows)
{
if (_bStopWork) break;
lsTemp = String.Empty;
lsTemp = row["UpdateSQL"].ToString() +
System.Environment.NewLine;
lsTemp.Replace("S","?");
sb.Append(lsTemp);
}

I am retrieving rows from a dataset to string and the replace is not
replacing the 'S''s like a assume they should.

Any ideas? Thanks!

Nov 5 '07 #2
On Nov 5, 3:48 pm, Soulless <dgmsal...@gmail.comwrote:
Hi,

I am tryng to use replace and it is not working. i'm surprised as it
would seem to be a simple method. My code:

foreach (DataRow row in dsSched.Tables["Schedule"].Rows)
{
if (_bStopWork) break;
lsTemp = String.Empty;
lsTemp = row["UpdateSQL"].ToString() +
System.Environment.NewLine;
lsTemp.Replace("S","?");
sb.Append(lsTemp);
}

I am retrieving rows from a dataset to string and the replace is not
replacing the 'S''s like a assume they should.

Any ideas? Thanks!
Replace returns the modified string seeing as strings are immutable.

Nov 5 '07 #3
Lew
Soulless wrote:
>I am tryng to use replace and it is not working. i'm surprised as it
would seem to be a simple method. My code:

foreach (DataRow row in dsSched.Tables["Schedule"].Rows)
{
if (_bStopWork) break;
lsTemp = String.Empty;
lsTemp = row["UpdateSQL"].ToString() +
System.Environment.NewLine;
lsTemp.Replace("S","?");
sb.Append(lsTemp);
}

I am retrieving rows from a dataset to string and the replace is not
replacing the 'S''s like a assume they should.
je**********@gmail.com wrote:
Replace returns the modified string seeing as strings are immutable.
N.b., the line
lsTemp = String.Empty;
is superfluous.

--
Lew
Nov 6 '07 #4
On Nov 5, 6:24 pm, Lew <l...@lewscanon.comwrote:
Soulless wrote:
I am tryng to use replace and it is not working. i'm surprised as it
would seem to be a simple method. My code:
foreach (DataRow row in dsSched.Tables["Schedule"].Rows)
{
if (_bStopWork) break;
lsTemp = String.Empty;
lsTemp = row["UpdateSQL"].ToString() +
System.Environment.NewLine;
lsTemp.Replace("S","?");
sb.Append(lsTemp);
}
I am retrieving rows from a dataset to string and the replace is not
replacing the 'S''s like a assume they should.
jehugalea...@gmail.com wrote:
Replace returns the modified string seeing as strings are immutable.

N.b., the line
lsTemp = String.Empty;

is superfluous.

--
Lew- Hide quoted text -

- Show quoted text -
Thanks for the replies!

Nov 6 '07 #5

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

Similar topics

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...
6
by: Danny | last post by:
I need an asp command to strip out from a string all extra punctuation such as apostrophe, comma, period, spaces dashes, etc etc and just leave the letters. Can anybody give me some ideas? ...
4
by: higabe | last post by:
Three questions 1) I have a string function that works perfectly but according to W3C.org web site is syntactically flawed because it contains the characters </ in sequence. So how am I...
12
by: Brian | last post by:
I want to use regxp to check that a form input contains at least 1 non-space charcter. I'd like to only run this if the browser supports it. For DOM stuff, I'd use if (documentGetElementById) {}...
3
by: Dave | last post by:
I have an Access 2K application that is distributed to about a dozen users (all with identical NT environments and identical Access versions, object libraries and service packs). I am using the VBA...
5
by: pembed2003 | last post by:
Hi all, I need to write a function to search and replace part of a char* passed in to the function. I came up with the following: char* search_and_replace(char* source,char search,char*...
19
by: Paul | last post by:
hi, there, for example, char *mystr="##this is##a examp#le"; I want to replace all the "##" in mystr with "****". How can I do this? I checked all the string functions in C, but did not...
5
by: djc | last post by:
I need to prepare a large text database field to display in an asp.net repeater control. Currently I am replacing all chr(13)'s with a "<br/>" and it works fine. However, now I also want to be able...
4
by: Lauren Wilson | last post by:
Hi folks, We have a need to replace sub strings in certain message text. We use the Office Assistant to display help and often use the imbedded formatting commands. Those of you who have used...
10
by: pamelafluente | last post by:
I need to replace all the occurences of a string within another string (or stringbuilder): Function ReplaceInsensitive(ByVal InputString As String, _ ByVal SubstringReplaced As String, _ ByVal...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.