Advertisement

06.12.2007 at 02:05PM PDT, ID: 22629701
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.4

Remove DataColumn Expression but make data persist

Asked by cheddar73 in Microsoft Visual Basic.Net, .NET, .NET Framework 2.x

Tags: , ,

Hi Experts,

This question:

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_22627604.html

...has inspired me to try to come up with a way to quickly apply update criteria to a single column in a DataTable without having to iterate the column's rows.  So that the result would be as if you could run an update statement against the table itself.  Something like:

UPDATE myTable SET column1 = 'updated' WHERE column1 = 'update_me'

Here's the solution I came up with, which doesn't work (yet):

Create a temporary column in the DataTable
Set the temp column's Expression property to an IIF statement applying the update crieria
Remove the Expression from the temp column but make the data persist (this is the part that doesn't work)
Set the Expression property of the column to be updated to the temp column
Remove the Expression from the column to be updated but make the data persist (again, won't work)
Remove the temp column

Here's a snippet I used to test this idea:

' Create the table
Dim dt As New DataTable
dt.Columns.Add("column1")
dt.Rows.Add("updated")
dt.Rows.Add("update_me")
DataGridView1.DataSource = dt

' Try to update using column Expression
dt.Columns.Add("temp")
dt.Columns("temp").Expression = "IIF(column1='update_me', 'updated', column1)
dt.Columns("temp").Expression = Nothing ' <--- this doesn't work; makes the data in temp go away

First, is this idea viable at all?  In order to make this work I need to remove an Expression from the temporary column, but make the data that are already in that column persist.  Is there a way to do that?

Second, my impression is that this method would be more efficient than iterating rows and updating values using a simple If block when the column has very many rows.  I wonder what the row count threshold would be to determine which method would be more efficient.  (I suppose I could answer this myself using some performance testing if I could just get it to work. :) )

Any input is appreciated.
Start Free Trial
[+][-]06.12.2007 at 02:12PM PDT, ID: 19269960

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual Basic.Net, .NET, .NET Framework 2.x
Tags: datacolumn, expression, remove
Sign Up Now!
Solution Provided By: VBRocks
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.12.2007 at 02:48PM PDT, ID: 19270240

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.12.2007 at 03:02PM PDT, ID: 19270341

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.12.2007 at 03:08PM PDT, ID: 19270382

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.12.2007 at 03:18PM PDT, ID: 19270423

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.12.2007 at 03:25PM PDT, ID: 19270455

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.12.2007 at 03:56PM PDT, ID: 19270600

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.12.2007 at 04:01PM PDT, ID: 19270631

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.12.2007 at 09:23PM PDT, ID: 19272096

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32