Click here to Skip to main content
15,892,161 members
Home / Discussions / C#
   

C#

 
AnswerRe: Running a method on a seperate thread Pin
Henry Minute2-Oct-10 3:32
Henry Minute2-Oct-10 3:32 
GeneralRe: Running a method on a seperate thread Pin
teknolog1232-Oct-10 3:44
teknolog1232-Oct-10 3:44 
AnswerRe: Running a method on a seperate thread [modified] Pin
Luc Pattyn2-Oct-10 3:51
sitebuilderLuc Pattyn2-Oct-10 3:51 
GeneralRe: Running a method on a seperate thread Pin
teknolog1232-Oct-10 13:37
teknolog1232-Oct-10 13:37 
AnswerRe: Running a method on a seperate thread Pin
Luc Pattyn2-Oct-10 14:17
sitebuilderLuc Pattyn2-Oct-10 14:17 
GeneralRe: Running a method on a seperate thread Pin
teknolog1233-Oct-10 5:11
teknolog1233-Oct-10 5:11 
GeneralRe: Running a method on a seperate thread Pin
Luc Pattyn3-Oct-10 5:18
sitebuilderLuc Pattyn3-Oct-10 5:18 
QuestionVisual diff of 2 DataTables Pin
Aaron D Anderson1-Oct-10 20:47
Aaron D Anderson1-Oct-10 20:47 
I would like to write an application that performs a visual diff of 2
DataTables. Let's call them source and destination. There are several
components to this that I would like to solicit opinions on.

I have written something that kind of works but I'm sure there are better
ways to do this. My application is a form that contains 2 DataGridViews, one tied to the source DataTable and the other tied to the destination DataTable.

My end goal is to have records that appear in destination but not in source show with a red background color, records that appear in source but not in destination show with a green background color and rows that have a difference in a field show up yellow (only the changed cell).

The user should then be able to select which source rows then want to propagate to the destination and which rows in the destination that should be deleted so that they match. Those changes will be applied by generating a .SQL file containing the necessary statements.

1) Performing the actual diff of the 2 DataTable objects -> I have read
several posts about table datatable1 and merging it in to datatable2 and
then using the GetChanges method to find out what changed. I never got this to work. Currently what I do is simply compare manually. For each record in the source I do a select against the destination using the primary key and then loop over each field. If the record doesn't appear in the destination, the background color on the source record is green. If the record appears, I color the cells which are different yellow. I then loop over the destination table checking the source table for the associated record. If it's not found I paint the background color of the row red.

My question is there a better way to perform the diff. The datasets that I'll be working with aren't that large but I'm pretty sure this isn't the most efficient way. The end result that I need are the changes in a way that I can generate the SQL to apply the changes to the destination database.

2) The way I'm currently setting the background color of the DGV is using the CellFormatting event in the DGV. Those event are responsible for performing the actual diff described above and setting the background color on the cell. This has several issues:
- I'm doing too many queries. Since this event runs against each cell, I effectively query for the presence of the row in the other DGV for each cell in the row. Not very efficient.
- The CellFormatting event is called on mouse over. I don't want this.
I've tried several different ways to set the background color but the only way that worked was usig the CellFormatting event. Simply trying to set the color doing dgv[0,0].Style.BackColor doesn't appear to do anything. Any suggestion on this is greatly appreciated.

I think I have the right concept just not executing it correctly. Any help is greatly appreciated.

Thanks.
AnswerRe: Visual diff of 2 DataTables Pin
Luc Pattyn2-Oct-10 4:10
sitebuilderLuc Pattyn2-Oct-10 4:10 
AnswerRe: Visual diff of 2 DataTables Pin
PIEBALDconsult2-Oct-10 15:48
mvePIEBALDconsult2-Oct-10 15:48 
QuestionDebug Break Pin
Richard Andrew x641-Oct-10 7:51
professionalRichard Andrew x641-Oct-10 7:51 
AnswerRe: Debug Break Pin
OriginalGriff1-Oct-10 8:16
mveOriginalGriff1-Oct-10 8:16 
GeneralRe: Debug Break Pin
Richard Andrew x641-Oct-10 8:22
professionalRichard Andrew x641-Oct-10 8:22 
GeneralRe: Debug Break Pin
OriginalGriff1-Oct-10 8:30
mveOriginalGriff1-Oct-10 8:30 
AnswerRe: Debug Break Pin
Abhinav S1-Oct-10 18:08
Abhinav S1-Oct-10 18:08 
QuestionDecoding non-ascii characters Pin
Chriso821-Oct-10 1:58
Chriso821-Oct-10 1:58 
AnswerRe: Decoding non-ascii characters Pin
Luc Pattyn1-Oct-10 2:10
sitebuilderLuc Pattyn1-Oct-10 2:10 
AnswerRe: Decoding non-ascii characters Pin
Chriso821-Oct-10 3:51
Chriso821-Oct-10 3:51 
GeneralRe: Decoding non-ascii characters Pin
Luc Pattyn1-Oct-10 4:47
sitebuilderLuc Pattyn1-Oct-10 4:47 
Questionhow to program cash drawer? Pin
Syed Shahid Hussain1-Oct-10 0:26
Syed Shahid Hussain1-Oct-10 0:26 
AnswerRe: how to program cash drawer? PinPopular
OriginalGriff1-Oct-10 0:34
mveOriginalGriff1-Oct-10 0:34 
JokeRe: how to program cash drawer? Pin
Sauro Viti1-Oct-10 0:51
professionalSauro Viti1-Oct-10 0:51 
GeneralRe: how to program cash drawer? Pin
OriginalGriff1-Oct-10 0:56
mveOriginalGriff1-Oct-10 0:56 
AnswerRe: how to program cash drawer? Pin
Luc Pattyn1-Oct-10 1:04
sitebuilderLuc Pattyn1-Oct-10 1:04 
AnswerRe: how to program cash drawer? Pin
PIEBALDconsult1-Oct-10 3:10
mvePIEBALDconsult1-Oct-10 3:10 

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.