 |

|
You might want to look into the built in functionality that is included in Visual Studio now. From the menu click Data -> Schema Compare -> New Schema Comparison...
I've tried it a couple of times already and it seems pretty comprehensive. Nice article by the way.
|
|
|
|
|

|
Respected Sir/Madam,
I am a student of MCA i would like to know how to run this program this would be very helpful for me.
thanks
Rupa V
|
|
|
|

|
Nice Work...!!! keep it up.
!- F - R - I - E - N - D - S -!
|
|
|
|

|
The error message is :
Error Comparing Database Objects
Cross thread operation not valid :
Control 'iv differences' accessed from a thread other than the thread it was created on...
Help me To solve this error
|
|
|
|
|
|

|
Its excellent utility. Please keep it up
My vote is 5.
Thanks,
Imdadhusen
sunaSaRa Imdadhusen
+91 99095 44184
+91 02767 284464
|
|
|
|

|
This has helped me tremendously. Thank you so much.
I have a question however, perhaps you can point me in the right direction to extend your existing code.
My ultimate goal is to compare the schema's of the actual individual tables. If I had a fictional table called "table1". Which tables would I have to query from the database to get the schema of "table1"?
Is there a good free resource on the web that might help me extend my database knowledge on this kind of stuff? I'm hoping to compare table schema's and then alter tables where necessary.
Kind Regards
|
|
|
|

|
Hi dude,
You helped me a lot with this project. wish you all the success in your career. The userTable comaparison i am trying to implement.
Once again thanx a lot...
--
Thanks
Ajith R Nair
|
|
|
|
|
|

|
D-softs DB Compare is not free unfortunately.
but it is cheap! $135.00 for 1 user license.
|
|
|
|

|
hi, that's a very nice tool. I have made a few improvements check them out here[^]
|
|
|
|

|
Great tool.... Thanks you very much
|
|
|
|

|
Thanks for the tool. It help me quickly determine which tables are different in two databases.
___________________________
I Love programming! Do you?
|
|
|
|

|
I am more interested in the Table/ table data comparing aspect of the project. Any pointers would help a lot. Thanks. And great tutorial although I am yet to digest it.
|
|
|
|

|
It does exactly what I need. Like you I try to keep a record of the changes I want to make to the production server but it gets tricky!
Take no notice of those individuals trying to sell their 'better' products.
|
|
|
|

|
Great tool. However, if you change the anchor behavior of the Grid it doesn't cut off the information and force scrolling. Just make the anchor for the Grid "All" and the anchor for the Get Change Script button to be bottom, right.
Other than that, very nice job and thank you very much!
|
|
|
|

|
Great Project Thanks,
By the way, when I try to run the source code I get following error message:
cross thread operation not valid
Corss-Thread operation not valid: Control 'lvDifferences' accessed from a thread other than the thread it was created
Could I know how to resolve that?
|
|
|
|

|
Well this shouldn't happen because I put the worker thread into a different thread from the UI so that the UI stays responsive.
It's been a while since I looked at the code, but you might convert it over to 2.0 and use the built in delegation methods versus "invokerequired" (or whatever the keyword is that you had to do in 1.1).
Or a couple posts down, someone gave a link to a really good tool that does more than this one that's free. You should give it a try!
|
|
|
|
|

|
I've not looked at the source code if forever, but I think that I wrote it so that the UI is responsive while the code is off scanning the databases. There will be something to the effect of:
QueueWorkItem( method ); // this is not right, but look for queue
This will start a new thread to do the work in the background while the UI will have its own thread to be responsive.
There will also be at least one method, which will take a delegate call to update the UI with information (ie, to update the text box with what's going on). This method (or methods) will have some code like:
if ( invokerequired )
invokedelegate(state)
This is not something that has to be done in 2.0 and it might be the source of the problem.
Unfortunately, I'm *super* swamped right now, or I'd take a closer look. Think of it as a learning excersize for you though... now you'll be more familiar with threading so you can become a super-stud software developer!
|
|
|
|

|
Add
CheckForIllegalCrossThreadCalls = false;
in the MainForm_Load section of code so you would have the following:
private void MainForm_Load(object sender, EventArgs e)
{
CheckForIllegalCrossThreadCalls = false;
}
VS 2005 checks for illegal cross threads where as prior versions did not. This code disables this check. After adding this line everything compiles fine and works.
Enjoy!
|
|
|
|

|
Setting CheckForIllegalCrossThreadCalls = false is not the best option.
The correct way to avoid this error on .NET Framework 2.0 and above is:
1) On the method btnCompareDatabases_Click replace
WaitCallback doWork = new WaitCallback( this.DoGatherDatabaseData );
ThreadPool.QueueUserWorkItem( doWork );
with
BackgroundWorker wk = new BackgroundWorker();
wk.DoWork += new DoWorkEventHandler(DoGatherDatabaseData);
wk.RunWorkerCompleted += new RunWorkerCompletedEventHandler(wk_RunWorkerCompleted);
wk.RunWorkerAsync();
2) On the method DoGatherDatabaseData replace
foreach( DBDifference d in differences )
{
lvDifferences.Items.Add( new ListViewItem( new string[] {d.Type, d.Name, d.Status } ) );
}
lvDifferences.Enabled = true;
btnChangeScript.Enabled = true;
with
e.Result = differences;
3)
Implement wk_RunWorkerCompleted as
private void wk_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Cancelled)
{
}
else if (e.Error != null)
{
}
else
{
ArrayList differences = (ArrayList)e.Result;
foreach (DBDifference d in differences)
{
lvDifferences.Items.Add(new ListViewItem(new string[] { d.Type, d.Name, d.Status }));
}
lvDifferences.Enabled = true;
btnChangeScript.Enabled = true;
}
}
|
|
|
|

|
I am trying to run this against 2 SQL2005 dbs located on seperate domains. If I run the tool from a machine on prod domain I get a message the the dev server is not configured, and if I try and run the tool from dev domain I get the message that the prod server is not configured correctly.
I can ping each server in the opposite environment.
Any help is greatly appreciated.
Thanks in advance.
|
|
|
|
|

|
Just save me the day of writting a tool. I'll check out your source code later. I really appreciate it man!
By the way, anybody who has the balls to comment on here about how another tool is better is an ingrateful dog who should be drug out and shot.
Peace bro
Christopher
|
|
|
|

|
Sean,
I needed to do a simple comparision to find missing tables and I swear to you that this did the job as advertised.
Thanks,
Kim Alexander
|
|
|
|

|
Thanks Kim
|
|
|
|

|
Best SoftTool, Inc. offers SQLDBCompare which can compare schema and data between two databases. If there is a difference, you can synchronize two objects at a finger tip. Please visit http://www.bestsofttool.com for more detailed information.
|
|
|
|

|
Of course it is... it's also not free either is it?
|
|
|
|

|
When asking for a change script I get the following:
-- Table product
-- Type unsupported
What does that mean?
|
|
|
|

|
It means that I didn't write the code to do this (since if there was data in the tables, I'd have to create temp tables and move data scripts). Also, I don't look at constrains and stuff.
This is just an intro, quick tool. It should take you a couple hours to make it much more robust if that's what you need it to do.
|
|
|
|

|
Checkout SQLDBDiff: http://www.sqldbtools.com/Tools.aspx?ProductId=1
Free
I'm more interested in an open source data comparison tool.
|
|
|
|

|
That is a pretty good looking tool!
Thanks!
|
|
|
|

|
You should use the views in INFORMATION_SCHEMA instead, this way the code will also work on SQL2005 databases without having to change a thing
|
|
|
|
|

|
I tested this against a couple SQL2005 DBs and it appears to work just fine?
The information_schema view structure does seem to incorporate the information in a lot simpler way to get at it though (with datatypes exposed and such).
Although, there is a problem with the information_schema.views view. I have a couple views that are very long (say 6000 characters). The information_schema.views table has a null in the view_definition column for those views, so I'd still have to go back to the syscomments table to get the definition. I'm a lazy programmer (aren't we all?), and I'd prefer to not get data from two different sources.
In fact, this is true of stored procs as well (missing data in the information_schema.routines view). SP's tend to be really long (esp. if there's embedded business logic -- not a good thing, but it happens a lot).
Thanks, I didn't even know the information_schema stuff existed (not a DBA by trade by any means)! Learned something new today, so I guess I can go play golf or something
|
|
|
|

|
The purpose of the views is to have a common interface against the system info tables.
That means that Microsoft can change the structure of these tables as long as they keep the views the same.
But if they don't provide you with sufficent information, I guess that quering the tables directly would be the next best solution.
Have you tested this tool on SQL 2005?
//seesharper
|
|
|
|

|
I ran it against some simple SQL2005 dbs locally, but no large databases. It appeared to work ok.
Most of my clients are still running SQL2000...
|
|
|
|
|

|
I can't get that tool to run....gives me CommonDialog errors....also their two email addresses on their site bounce......seems to be a dead product.
|
|
|
|
|

|
I was starting something simple like this, but this code gave me all I was expecting. Less work this week
great job!
|
|
|
|

|
Thanks! Make sure you pretend to work really hard for at least a couple hours on it when your boss is around!
|
|
|
|

|
Downloads to an invalid file.
P.S. AWESOME ARTICLE!!!
|
|
|
|

|
Sorry 'bout that (and sorry so late responding, I never got an email from CodeProject about it).
I reuploaded the demo archive. It works from my machine now (it wasn't working earlier for me either).
Thanks!
|
|
|
|

|
What a great tool. I have looked at others in the past that were open source and most were buggy at best. I just ran the tool quickly and it appears to work great.
|
|
|
|

|
bvermilion wrote: I just ran the tool quickly and it appears to work great
I also just had a quick look and agree with bvermilion.
One picky item I have is when generating a change script, it produces the results in lowercase. Rather than converting both database objects scripts to lowercase, it should simply do a case insensitive text comparison on them. It would be a better practice to produce the change script exactly the same as it was retrieved from the corresponding database.
I can't think of an exact instance where the case will matter with the default case insensitive collation, but it could lead to problems down the line.
Further, the databases I tested the app on have different owners. Development server of [dbo] and staging server of [specificdbo]. As a feature you may like to add in the future would be to translate/ignore the database owner for situations like this. It gave me a change script for everything
Great work otherwise!
|
|
|
|
 |