Click here to Skip to main content
15,895,256 members
Home / Discussions / Database
   

Database

 
GeneralRe: SQL - DELETE Directive error Pin
ddmcr21-Oct-05 3:54
ddmcr21-Oct-05 3:54 
GeneralRe: SQL - DELETE Directive error Pin
André Ziegler21-Oct-05 5:15
André Ziegler21-Oct-05 5:15 
QuestionDisplaying date Pin
Anonymous21-Oct-05 3:25
Anonymous21-Oct-05 3:25 
AnswerRe: Displaying date Pin
Hesham Amin22-Oct-05 4:48
Hesham Amin22-Oct-05 4:48 
GeneralRe: Displaying date Pin
Anonymous23-Oct-05 23:04
Anonymous23-Oct-05 23:04 
Questioncalander value using query Pin
Member 184400621-Oct-05 2:24
Member 184400621-Oct-05 2:24 
QuestionSearching for a list of words Pin
hasanali0021-Oct-05 1:59
hasanali0021-Oct-05 1:59 
QuestionFind an replace text in Row in a DataTable Pin
blackhole07720-Oct-05 11:59
blackhole07720-Oct-05 11:59 
Hi,

I was wondering if there was a better way of reading, updating and writing back text contained in a row in a DataTable in memory.

I need to read the text in a DataRow, and replace one character with another. For example, replace periods with backslashes.

Currently my code does this.

<br />
....<br />
DataTable convertperiodtoslash = new DataTable();<br />
sqlDataAdapter.Fill(convertperiodtoslash);<br />
foreach(DataRow dr in convertperiodtoslash.Rows)<br />
			{<br />
				foreach(DataColumn col in convertperiodtoslash.Columns)<br />
				{<br />
					dr[col] = dr[col].ToString().Replace(".", "\\");<br />
				}<br />
			}	


Everything works fine, except that when there are 50,000 rows it takes around 10 mins to process. For smaller number of rows, say around 2000 or so it only takes seconds. So I was wondering if there was a better way of doing this update.. better meaning faster/more efficient code.

I found that the part which slows down the whole process is the writing back into the DataTable. If I write the modified text back into a string array it takes only 5-10 seconds to process even 50,000 rows.

dr[col] = (modified text)
^
|----> bottleneck

Any suggestions/recommendations will be greatly appreciated !!
Thanks in advance!

C# Noob.. Poke tongue | ;-P
AnswerRe: Find an replace text in Row in a DataTable Pin
S Douglas20-Oct-05 22:52
professionalS Douglas20-Oct-05 22:52 
GeneralRe: Find an replace text in Row in a DataTable Pin
blackhole07721-Oct-05 9:46
blackhole07721-Oct-05 9:46 
GeneralRe: Find an replace text in Row in a DataTable Pin
S Douglas23-Oct-05 22:01
professionalS Douglas23-Oct-05 22:01 
GeneralRe: Find an replace text in Row in a DataTable Pin
blackhole07724-Oct-05 9:27
blackhole07724-Oct-05 9:27 
GeneralRe: Find an replace text in Row in a DataTable Pin
S Douglas24-Oct-05 12:29
professionalS Douglas24-Oct-05 12:29 
GeneralRe: Find an replace text in Row in a DataTable Pin
S Douglas23-Oct-05 23:40
professionalS Douglas23-Oct-05 23:40 
GeneralRe: Find an replace text in Row in a DataTable Pin
blackhole07729-Oct-05 18:24
blackhole07729-Oct-05 18:24 
GeneralRe: Find an replace text in Row in a DataTable Pin
S Douglas30-Oct-05 16:05
professionalS Douglas30-Oct-05 16:05 
QuestionDetermining whether DataRow values have changed Pin
GazzaJ20-Oct-05 5:55
GazzaJ20-Oct-05 5:55 
QuestionSomeone answer my questions,please! Pin
Deema Jack20-Oct-05 2:55
Deema Jack20-Oct-05 2:55 
AnswerRe: Someone answer my questions,please! Pin
Colin Angus Mackay20-Oct-05 6:35
Colin Angus Mackay20-Oct-05 6:35 
QuestionWeb part database access Pin
phy6njsb20-Oct-05 0:30
phy6njsb20-Oct-05 0:30 
AnswerRe: Web part database access Pin
Michael Potter20-Oct-05 11:23
Michael Potter20-Oct-05 11:23 
GeneralRe: Web part database access Pin
phy6njsb20-Oct-05 22:48
phy6njsb20-Oct-05 22:48 
GeneralRe: Web part database access Pin
Michael Potter21-Oct-05 3:21
Michael Potter21-Oct-05 3:21 
GeneralRe: Web part database access Pin
phy6njsb23-Oct-05 22:54
phy6njsb23-Oct-05 22:54 
GeneralRe: Web part database access Pin
Michael Potter24-Oct-05 3:15
Michael Potter24-Oct-05 3:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.