Before displaying the result of a table called "people" in a datagrid
called "mydatagrid", I need to modify the content of a column called
"moreinfo" in the in-memory datatable (but not the corresponding table
of the database).
I was thinking of doing something like this:
Dim strSQL as string = "Select ID, firstname, lastname, moreinfo from
people order by lastname"
Dim myConnection As MySqlConnection = New
MySqlConnection(connectionstring)
Dim myDataAdapter As MySqlDataAdapter = New MySqlDataAdapter(strSQL,
myConnection)
Dim myDataSet As DataSet = new Dataset
Dim row As DataRow
Dim searchstring as string = "colour"
Dim replacestring as string = "color"
myDataAdapter.Fill(mydataset, "mytable")
For Each row In myDataSet.Tables("tbl").Rows
Replace(row("moreinfo"), searchstring, replacestring)
Next
mydatagrid.DataSource = myDataSet.Tables("tbl") 'datagrid previously
defined
mydatagrid.DataBind()
However when the datagrid is displayed, no replace action seems to have
taken place, as the original data (including the word "colour") of the
"moreinfo" column of the "people" table is displayed instead.
What am I doing wrong here?
Thanks
TB 2 2140
Hi TB,
It should be
For Each row In myDataSet.Tables("tbl").Rows
row("moreinfo") = row("moreinfo").ToString.Replace(searchstring,
replacestring)
Next
HTH
Elton Wang
"TB" wrote: Before displaying the result of a table called "people" in a datagrid called "mydatagrid", I need to modify the content of a column called "moreinfo" in the in-memory datatable (but not the corresponding table of the database).
I was thinking of doing something like this:
Dim strSQL as string = "Select ID, firstname, lastname, moreinfo from people order by lastname" Dim myConnection As MySqlConnection = New MySqlConnection(connectionstring) Dim myDataAdapter As MySqlDataAdapter = New MySqlDataAdapter(strSQL, myConnection) Dim myDataSet As DataSet = new Dataset Dim row As DataRow Dim searchstring as string = "colour" Dim replacestring as string = "color" myDataAdapter.Fill(mydataset, "mytable") For Each row In myDataSet.Tables("tbl").Rows Replace(row("moreinfo"), searchstring, replacestring) Next
mydatagrid.DataSource = myDataSet.Tables("tbl") 'datagrid previously defined mydatagrid.DataBind()
However when the datagrid is displayed, no replace action seems to have taken place, as the original data (including the word "colour") of the "moreinfo" column of the "people" table is displayed instead.
What am I doing wrong here?
Thanks
TB
Of course!
Thanks a lot.
TB This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jane Doe |
last post by:
Hi,
I need to search and replace patterns in web pages, but I
can't find a way even after reading the ad hoc chapter in New Rider's
"Inside JavaScript".
Here's what I want to do:
function...
|
by: vic |
last post by:
My manager wants me to develop a search program, that would work like they
have it at edorado.com.
She made up her requirements after having compared how search works at
different websites, like...
|
by: Ryan |
last post by:
I'm looking for a stored procedure (or query) to search an entire
database for a specific string value and replace it with another. I'm
sure I saw an SP for this a while back by someone, but cannot...
|
by: DraguVaso |
last post by:
Hi,
I have a ComboBox of +- 15.000 items in it, via a DataSource. On Top of the
Items-list, I want to add some values, based on a user choise (via a filter
on the DataSource). Does anybody know...
|
by: tshad |
last post by:
Can you do a search for more that one string in another string?
Something like:
someString.IndexOf("something1","something2","something3",0)
or would you have to do something like:
if...
|
by: Niyazi |
last post by:
Hi all,
I have a dataTable that contains nearly 38400 rows.
In the dataTable consist of 3 column.
column 1 Name: MUHNO
column 2 Name: HESNO
Column 3 Name: BALANCE
Let me give you some...
|
by: Terry |
last post by:
Hi,
I am both new to .Net (coming from VB6 and DAO) and to this news group. I
am trying to convert some code from VB6 that uses a "record set" to help the
user locate a specific record.
As the...
|
by: Rich |
last post by:
Hello,
I need to store various values that I will need to look up later on. I have
been using hashtables and arraylists. But I can only store 2 items per row
in a hashtable - key, value, and...
|
by: JamesOo |
last post by:
I have the code below, but I need to make it searchable in query table,
below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only,...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |