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

Running trough a Table of a DataSet



I have a dataset with a table "Artikler". Before I bind the table to a
DataList in my Web Form I want to update the value of each row of the field
"PreText" in the table. (I don't want to update the database only the local
data of the DataSet Table) I want to replace all the occuranse of chr(13)
with the <brtag.

01 myDataAdapter.Fill(myDataSet, "Artikler")

02 code for running trough the table and update the field "PreText" for
all rows

03 DataList1.DataSource = myDataSet.Tables("Artikler")

04 DataList1.DataBind()

I need some help filling in the code of line 02

TIRislaa


Nov 15 '06 #1
5 1261
On Wed, 15 Nov 2006 22:53:08 +0100, "Tor Inge Rislaa"
<to************@rislaa.nowrote:
>

I have a dataset with a table "Artikler". Before I bind the table to a
DataList in my Web Form I want to update the value of each row of the field
"PreText" in the table. (I don't want to update the database only the local
data of the DataSet Table) I want to replace all the occuranse of chr(13)
with the <brtag.

01 myDataAdapter.Fill(myDataSet, "Artikler")

02 code for running trough the table and update the field "PreText" for
all rows

03 DataList1.DataSource = myDataSet.Tables("Artikler")

04 DataList1.DataBind()

I need some help filling in the code of line 02

TIRislaa

You have 2 was of going about it
1) Replacing the newlines with <BRas you output the datalist, using
the Replace method of the string object
2) Doing it in your sql statement such that the data already has the
<BRinserted

Looping after loading will introduce a performance penalty, especially
if you have a lot of data

Depending on how many pages you have, method 2 might be less hassle
Nov 15 '06 #2
foreach (DataRow row in Artikler)
{

row["PreText"]=((string)row["PreText"]).Replace("\n","<BR>");
}

I think \n is the chr(13), if not then its the \r in the \r\n end of line
sequence.
Cheers.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Tor Inge Rislaa" wrote:
>

I have a dataset with a table "Artikler". Before I bind the table to a
DataList in my Web Form I want to update the value of each row of the field
"PreText" in the table. (I don't want to update the database only the local
data of the DataSet Table) I want to replace all the occuranse of chr(13)
with the <brtag.

01 myDataAdapter.Fill(myDataSet, "Artikler")

02 code for running trough the table and update the field "PreText" for
all rows

03 DataList1.DataSource = myDataSet.Tables("Artikler")

04 DataList1.DataBind()

I need some help filling in the code of line 02

TIRislaa


Nov 15 '06 #3
The problem with the replacement in the SQL statement is that the datatype
of the datafield is TEXT and this is not a valid parameter within the
replace syntax. If you know of a better method then using replace in
Transact SQL I would like to know about it.

"Rad [Visual C# MVP]" <no****@nospam.comskrev i melding
news:g3********************************@4ax.com...
On Wed, 15 Nov 2006 22:53:08 +0100, "Tor Inge Rislaa"
<to************@rislaa.nowrote:
>>

I have a dataset with a table "Artikler". Before I bind the table to a
DataList in my Web Form I want to update the value of each row of the
field
"PreText" in the table. (I don't want to update the database only the
local
data of the DataSet Table) I want to replace all the occuranse of chr(13)
with the <brtag.

01 myDataAdapter.Fill(myDataSet, "Artikler")

02 code for running trough the table and update the field "PreText" for
all rows

03 DataList1.DataSource = myDataSet.Tables("Artikler")

04 DataList1.DataBind()

I need some help filling in the code of line 02

TIRislaa


You have 2 was of going about it
1) Replacing the newlines with <BRas you output the datalist, using
the Replace method of the string object
2) Doing it in your sql statement such that the data already has the
<BRinserted

Looping after loading will introduce a performance penalty, especially
if you have a lot of data

Depending on how many pages you have, method 2 might be less hassle

Nov 15 '06 #4
Ok, one more time: that should have been:

foreach (DataRow row in Artikler.Rows)

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Tor Inge Rislaa" wrote:
>

I have a dataset with a table "Artikler". Before I bind the table to a
DataList in my Web Form I want to update the value of each row of the field
"PreText" in the table. (I don't want to update the database only the local
data of the DataSet Table) I want to replace all the occuranse of chr(13)
with the <brtag.

01 myDataAdapter.Fill(myDataSet, "Artikler")

02 code for running trough the table and update the field "PreText" for
all rows

03 DataList1.DataSource = myDataSet.Tables("Artikler")

04 DataList1.DataBind()

I need some help filling in the code of line 02

TIRislaa


Nov 15 '06 #5
Thank you Peter

TIR
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comskrev i melding
news:FA**********************************@microsof t.com...
Ok, one more time: that should have been:

foreach (DataRow row in Artikler.Rows)

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Tor Inge Rislaa" wrote:
>>

I have a dataset with a table "Artikler". Before I bind the table to a
DataList in my Web Form I want to update the value of each row of the
field
"PreText" in the table. (I don't want to update the database only the
local
data of the DataSet Table) I want to replace all the occuranse of chr(13)
with the <brtag.

01 myDataAdapter.Fill(myDataSet, "Artikler")

02 code for running trough the table and update the field "PreText"
for
all rows

03 DataList1.DataSource = myDataSet.Tables("Artikler")

04 DataList1.DataBind()

I need some help filling in the code of line 02

TIRislaa



Nov 16 '06 #6

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

Similar topics

0
by: Giorgio | last post by:
Hi I have Win 2000 and PHP server in my PC I'm trying to run SlimBrowser (sbrowser.exe) from a local PHP page. I have used exec() system(). I managed to run SlimBrowser with .exe and .bat...
4
by: Radek Michalski | last post by:
Hi! I'm looking for a macro, that let me pass trough all rows in table (ID int - key, string Name) and everytime calls a query with a Name (or ID) as parameter. I can't find this kind of macro....
3
by: Antoine Junod | last post by:
Hello, I definitely have a problem to build a clean data structure. I would be very happy if some of you could help me as well as in the past. Here is my problem: -> I have a list of...
1
by: Thanks | last post by:
I have a routine that is called on Page_Init. It retrieves folder records from a database which I display as Link Buttons in a table cell. I set the table cell's bgcolor to a default color (say...
3
by: Sandra Castellanos | last post by:
I want to know if there is a way to easily iterate trough all the controls contained, say, in a table, including the controls that can be inside the cells and in any nested tables that are inside?...
2
by: John | last post by:
Hi Is it possible to do run a select query on a dataset from a web method using a dataadapter? A code example would be great. If not, how can we grab hold of the remote dataset data in a local...
22
by: EMW | last post by:
Hi, I managed to create a SQL server database and a table in it. The table is empty and that brings me to my next chalenge: How can I get the info in the table in the dataset to go in an empty...
5
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I...
3
by: iKiLL | last post by:
Hi all I am having problems getting my SqlCeDataAdapter to Update the SQL Mobile Data base. i am using C# CF2. I have tried this a number of different ways. Starting with the command builder...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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: 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...

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.