Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace chararcter in dataset (vb)

Status
Not open for further replies.

Rexxx

MIS
Oct 16, 2001
47
0
0
I have a dataset named company and I am trying to replace every character (^) in the rows of a certain column (coname) with another character ('). Code I have is follows:

For i = 0 to ds.Tables.Count -1
Replace(ds.Tables("company").Rows(i).Item("coname"), "^", "'")
Next

Problem is, this apparently isn't storing the changed items. What do I need to add to get the rows that get changed to stay changed within this dataset company?
 
Hey Rexxx when you are doing this the value is not actually being stored. The string in 'coname' with the new character/s is returned by the replace function. If you want the value to be stored in the data set then use that value that is coming out of the replace function.

like this
mystring = replace(mystring, "^", "'")

replacing mystring with your dataset row, column combo.

HTH That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
vb Solution that works:

dim temp as string
For i = 0 to ds.Tables(0).Rows.Count - 1
temp = Replace(ds.Tables("company").Rows(i).Item("coname"), "^", "'")
ds.Tables("company").Rows(i).item("coname") = temp
Next

or table specific

For i = 0 to ds.Tables("partner").Rows.Count - 1
temp = Replace(ds.Tables("partner").Rows(i).Item("oname"), "^", "'")
ds.Tables("partner").Rows(i).item("oname") = temp
Next
 
thats what I said.

you can skip the temp bit too.

ds.Tables("partner").Rows(i).item("onName") = replace(ds.Tables("partner").Rows(i).item("onName"), "^","'") That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top