 |
|
|
 |
|
 |
Hi, this is Great work, thanks a lot!
I only noticed one thing..
I was copying two tables, between which there was a foreign key relationship. But the program does not run the foreign key creation code if I dont select the Copy Data option in the interface. That misleaded me a bit, but anyway i got it working!
You saved my life!
BTW, on idea for a future version: Could extracting the script of a given SqlCE be done? I love the Script-To abilities of Mangement Studio but I dont knwo what the MS guys were thinking by not implementing that so handy feature in the CE environment.
|
|
|
|
 |
|
 |
Hi,
The main procedure DoCopy() has a lot of nested conditions (maybe a little code refactoring will be nice ) and the part with the comment "Now add the FK relationships" is included in the data process copy ! You have to correct and move the FK relationship creation process out of the Data Copy process.
François.
|
|
|
|
 |
|
 |
So this is probably more of a general issue of moving from SQL to SQL Compact, but maybe you have a suggestion.
We've got a bunch of Small data types on the SQL Server (e.g., SmallDateTime). It appears that Compact only has DateTime.
So... what's the solution for this? I rather not have to turn all our SmallDateTime's to DateTimes (4 bytes to 8 Bytes) on our multi-million row DB.
We actually are planning on using Microsoft.Sync services to keep the DB's in sync, so this is a general problem.
Any suggestions?
I have been able to get around this in WizardForm.cs by adding a type conversion:
case SqlDataType.SmallDateTime:
max = col.DataType.MaximumLength;
col.DataType = new DataType(SqlDataType.DateTime);
col.DataType.MaximumLength = max;
break;
and can probably do the same for the various other small types (looks like SmallMoney is the other one that will cause issues, as SmallInt is present in Compact).
Thanks! (And VERY handy tool!)
-Greg
|
|
|
|
 |
|
 |
Your tool is very useful, it help me much.
I have a note that it lacks ON DELETE, ON UPDATE actions when creating FK constraints. I made a slight change in your code and it works fine for me.
void DoCopy()
{
...
string fkSql = "ALTER TABLE [{0}] ADD CONSTRAINT [{1}] FOREIGN KEY([{2}]) REFERENCES [{3}] ([{4}]) ON DELETE {5} ON UPDATE {6} ";
...
string createFKSql = String.Format(fkSql,
tbl.Name,
fk.Name,
"{0}",
fk.ReferencedTable,
sourceDb.Tables[fk.ReferencedTable].Indexes[fk.ReferencedKey].IndexedColumns[0].Name,
fk.DeleteAction.ToSql(), fk.UpdateAction.ToSql());
...
}
internal static class ForeignKeyActionExtensions
{
public static string ToSql(this ForeignKeyAction action)
{
switch (action)
{
case ForeignKeyAction.Cascade: return "CASCADE";
case ForeignKeyAction.NoAction: return "NO ACTION";
case ForeignKeyAction.SetDefault: return "SET DEFAULT";
case ForeignKeyAction.SetNull: return "SET NULL";
}
throw new InvalidEnumArgumentException("action", (int)action, typeof(ForeignKeyAction));
}
}
|
|
|
|
 |
|
 |
i have a project builded using VB6 and SQL Server whoich LAN anabled. I want to copy from all client pc's data daily and dump it to server pc.
|
|
|
|
 |
|
 |
Absolutely brilliant tool. You can edit SQL Server CE databases directly using the Management Studio, but it's a poor interface to say the least. And there's a lot of things you can't do that you can normally do with SQL Server databases. Just renaming a field in a table is more work than it should be.
This tool is a big help. Now you can manage your compact database in SQL Server and generate the database from that... Great!
What I would like to see next is the ability to synchronize data from your compact database back to the sql server, because let's say you design the database in SQL Server, perhaps fill it with some data. The you export everything to a compact database and run your application that adds further data to the database. Then at some time, you need to change the layout of the database (which of course you want to do in SQL Server Management Studio), but you don't want to lose the data that has been added to the compact database in the mean time... You get my point, I'm sure...
You've got my 5 for this! HOWEVER - I don't like the name of your site...
/Johnny J.
PS: A small but useful feature would be if the program could automatically scan the system for the needed dll's.
|
|
|
|
 |
|
 |
Hi.. Your tools works great and that is really what I need, however I require 3rd party tools to open the .sdf file after conversion
I could not open the .sdf file with SQL Server Management Studio Express
i get the following error
===================================
Cannot connect to C:\temp\GTAccDB.sdf.
===================================
You are trying to access an older version of a SQL Server Compact Edition database. If this is a SQL Server CE 1.0 or 2.0 database, run upgrade.exe. If this is a SQL Server Compact Edition 3.0 or later database, run Compact / Repair. [ Db version = 3505053,Requested version = 3004180,File name = C:\temp\GTAccDB.sdf ] (SQL Server Compact Edition ADO.NET Data Provider)
------------------------------
Program Location:
at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
at System.Windows.Forms.Control.Invoke(Delegate method)
at Microsoft.SqlServer.Management.UI.ConnectionDlg.Connector.ConnectionThreadUser()
However, when i view in it SQL CEVIEWER From
http://sourceforge.net/project/showfiles.php?group_id=204776
it shows that my version is MS SQL Compact 3.5
Is there anyway to solve this problem?
|
|
|
|
 |
|
 |
Sql Server Management Studio Express cannot open SQL Compact 3.5 version databases. I believe the new SQL 2008 management tools can open them. If you want to be able to manage your compact database with Sql Server 2005 Management Studio then you will need to convert it to a 3.1 version of the SQL Compact Database.
|
|
|
|
 |
|
 |
When trying to copy a SQL2000 database, I get an error message {"Operation not supported on SQL Server 2000."} at line 75 in file TablesCtrl.cs
Possible solution: Build an if block
if (db.CompatibilityLevel != CompatibilityLevel.Version80)
{
foreach (Schema schema in db.Schemas)
...
}
Because no schema list is generated with SQL Server 2000 the next error is coming up.
File WizardForm.cs line 414
change following line:
Table tbl = sourceDb.Tables[tblName, tableCtrl1.SchemaName];
to
Table tbl = null;
if (tableCtrl1.SchemaName == "")
tbl = sourceDb.Tables[tblName];
else
tbl = sourceDb.Tables[tblName, tableCtrl1.SchemaName];
The next problem is with some SqlDataTypes. Not all type are possible in the compact version. Therefore a convertion must be made for this data types (etc. SmallDataTime convert in DateTime).
File WizardForm.cs line 469 insert following case for SqlDateType.SmallDateTime
case SqlDataType.SmallDateTime:
col.DataType = new DataType(SqlDataType.DateTime);
break;
Maybe some more convertion are needed.
On the other hand: A great job done - thanks
Eckmar from Germany
|
|
|
|
 |
|
 |
What version are you using?
|
|
|
|
 |
|
 |
I am using Visual Studio 2008 currently.
|
|
|
|
 |
|
 |
Hi,
I had issues copying data from a Sql Server 2005 database. It keeps complaining that it cannot find the table.
I had to change to code to specify the schema when getting the source table:
Table tbl = sourceDb.Tables[tblName, "dbo"];
This seemed to sort out the issue.
Another issue I had was with the version of the SqlCe. There is a specific version (3.0.5207.0) that comes with Sql Server 2005 and the tool was looking for another version. I just added a "OR" statement and it worked great.
Thanks for a great tool. It saved me a lot of work.
charl
|
|
|
|
 |
|
 |
Could you provide me with the code you changed as well as the line numbers? If so I will update the source code so everyone will have these changes. Thanks
|
|
|
|
 |
|
 |
Hi,
These are the changes I made:
WizardForm.cs
Line 105: if (ver.FileVersion == "3.0.5300.0" || ver.FileVersion == "3.0.5207.0")
Line 414, 604, 724: Table tbl = sourceDb.Tables[tblName, "dbo"];
That's all the changes I made and it worked as expected.
I see there are some instances in the MainForm.cs where you also check the file version, but I am not sure if this is getting executed at all.
Regards,
Charl
charl
|
|
|
|
 |
|
 |
Hi.
This utility copy triggers and SP?
Thanks.
|
|
|
|
 |
|
 |
SQL Server Compact Edition does not support Views, Triggers nor Stored Procedures. Therefor this utility does not copy any of these.
|
|
|
|
 |
|
 |
Excuse my ignorance, thank you to respond me.
Greetings.
|
|
|
|
 |
|
 |
Triggers and SP not supported in compact edition.
--
ATB
Charles Kincaid
|
|
|
|
 |