473,385 Members | 1,907 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.

remove chars from field in dataset

How do you remove all chars such as carriage return and new line from a
particular field for all records in a dataset?
*** Sent via Developersdex http://www.developersdex.com ***
Feb 9 '07 #1
2 7138
Found the answer :

foreach(DataRow dr in ds.Tables["LeadDetails"].Rows)
{
dr["Activity"] = dr["Activity"].ToString().Replace("\r", "");
dr["Activity"] = dr["Activity"].ToString().Replace("\n", "");
dr["Activity"] = dr["Activity"].ToString().Replace("\t", "");
}

*** Sent via Developersdex http://www.developersdex.com ***
Feb 9 '07 #2
Mike P wrote:
Found the answer :

foreach(DataRow dr in ds.Tables["LeadDetails"].Rows)
{
dr["Activity"] = dr["Activity"].ToString().Replace("\r", "");
dr["Activity"] = dr["Activity"].ToString().Replace("\n", "");
dr["Activity"] = dr["Activity"].ToString().Replace("\t", "");
}

*** Sent via Developersdex http://www.developersdex.com ***
You do a lot of indexing and converting for no reason. You don't have to
put the value back for each operation.

foreach(DataRow dr in ds.Tables["LeadDetails"].Rows) {
dr["Activity"] = ((string)dr["Activity"]).Replace("\r",
string.Empty).Replace("\n", string.Empty).Replace("\t", string.Empty);
}

or using the Regex class:

foreach(DataRow dr in ds.Tables["LeadDetails"].Rows) {
Regex.Replace((string)dr["Activity"], "[\\r\\n\\t]", string.Empty);
}

--
Göran Andersson
_____
http://www.guffa.com
Feb 10 '07 #3

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

Similar topics

0
by: HarryMangurian | last post by:
I have a memo field in an ACCES database (up to 650000 characters). I have set up an adapter and a dataset for the database. I have a datagrid bound to the dataset. There are 4 fields in the...
2
by: John | last post by:
Hi I am trying to display the no of characters in a text field while user is typing them. I am using the onchange event as follows; Private Sub mytextfield_Change() Me.chars =...
2
by: lesperancer | last post by:
I've read all the posts, but nothing works I've got a table with an ID field and a memo field one record in the table, with the memo field having 322 chars I open the table, and then use the...
3
by: WJ | last post by:
..Net Experts, I have this concept described below: 1. I have a large (4K+) data record called Health_R. This record also contains Text/memo fields and Image. 2. The record layout is below:...
1
by: Jeff | last post by:
A client showed me this one. In a totals query that counts items and links to a parent record, what should be the output from a memo field shows up as Chinese characters - I kid not. He has a...
5
by: Alex | last post by:
Hi all - Is there a standard way to handle special chars in strings in dotnet? I'm using csharp and having two seperate problems... 1. Passing in args... I need to pass in an arg that...
2
by: Cliff72 | last post by:
I'm creating a database that will be uploading some text files into an access table. The problem is that the text files have a header which messes up my import specs. so what i have had to do is to...
2
by: mccalla | last post by:
Hi, I am very new to MS Access. I have inherited an existing app which was done in MS Access 2003. In this app, there is a report which contains a memo field. There are no formats, functions,...
10
by: Mike Copeland | last post by:
I have data I need to normalize - it's "name" data. For example, I have the following: "Watts, J.C." I wish to (1) parse the "first name" ("J.C.") and adjust it to "JC". Essentially, I want to...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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...
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
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,...
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...

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.