|
Well, I decided not to write a used ID and now it says:
"You do not have permissions to save the file to C:\. Please select a different destination path and try again"
and this happens with any paths a try.
Regards
|
|
|
|
|
Hello,
I have used SQL Compact previously and I never used the "USER" property. At the moment the code is looking for a Locale Identifier (LCID) which a four digit country code:
CultureInfo myCIintl = new CultureInfo("en-AU", false);
Console.WriteLine(myCIintl.LCID);
Console.ReadLine();
This all has nothing to do with the connection string. Change the string to:
string mobileConnStr = "Data Source='{0}';Persist Security Info=True;Password={2};Encrypt={3};SSCE:Max Database Size=4091;";
in the file OutputCtrl.cs (to be found in the Control folder)
http://www.connectionstrings.com/sql-server-2005-ce[^]
|
|
|
|
|
Hi Johnny,
Nice tool you've created. It certainly fills the lack which MS leaves and avoids manual scripting.
I've noticed two things which caused minor problems: if a column in SQL Server has GETUTCDATE() as default value, there's an issue because CE does not have this function.
So I've solved this by adding the next line in WizardForm.cs - DoCopy():
if (col.DefaultConstraint != null && !String.IsNullOrEmpty(col.DefaultConstraint.Text))
{
col.DefaultConstraint.Text = col.DefaultConstraint.Text.Replace("(getutcdate())", "(getdate())");
string def = col.DefaultConstraint.Text.Replace("((", "(").Replace("))", ")");
sb.Append(" DEFAULT ").Append(col.DefaultConstraint.Text);
}
The second thing I encountered is the script-creation for a ForeignKey on Multi-Column Key's.
Only the first referenced column was included and there was a problem with the square brackets.
string createFKSql = String.Empty;
if (sourceDb.Tables[fk.ReferencedTable].Indexes[fk.ReferencedKey].IndexedColumns.Count == 1)
{
createFKSql = String.Format(fkSql, tbl.Name, fk.Name, "{0}", fk.ReferencedTable, sourceDb.Tables[fk.ReferencedTable].Indexes[fk.ReferencedKey].IndexedColumns[0].Name);
}
else if (sourceDb.Tables[fk.ReferencedTable].Indexes[fk.ReferencedKey].IndexedColumns.Count > 1)
{
createFKSql = String.Format(fkSql, tbl.Name, fk.Name, "{0}", fk.ReferencedTable, "{1}");
string referencedColumns = String.Empty;
foreach(IndexedColumn iCol in sourceDb.Tables[fk.ReferencedTable].Indexes[fk.ReferencedKey].IndexedColumns)
{
if (referencedColumns.Length > 0)
referencedColumns = referencedColumns + "], [";
referencedColumns = referencedColumns + iCol.Name;
}
createFKSql = String.Format(createFKSql, "{0}", referencedColumns);
}
StringBuilder sbFk = new StringBuilder();
foreach (ForeignKeyColumn col in fk.Columns)
{
if (sbFk.Length > 0)
sbFk.Append("], [");
sbFk.Append(col.Name);
}
But, as I said: only minor issues on a great tool
Sorry if I haven't used the 'best' coding-practice on these snippets, but I'm not a C#, but VB.Net developer.
Kind regards,
Michael
|
|
|
|
|
For the other SQL Server CE 3.5 SP1 people, I was able to get it to work by modifying SelectMobileAssembliesDialog.cs line 98 to:
if (ver.FileMajorPart == 3 && ver.FileMinorPart == 5)
Also, I ran into some issue in the FinishCtrl.cs trying to update the progress bar based on the number of rows. As I was only using this for a POC, I didn't debug it (I think my data made it! and instead hacked lines 58 & 59 to say:
progressBar1.Maximum = Math.Max( value, max );
progressBar1.Value = Math.Min( value, max );
Other than that it worked great! Thank you very, very much for developing this tool, and for releasing the source to the community.
|
|
|
|
|
Seems very polished but I use SQL 2008 express at home. Any chance of adding support for that soon?
|
|
|
|
|
I had this error whiloe trying to upgrade database
"The specified data type is not valid. [ Data type (if known) = Timestamp ]"
please help me
|
|
|
|
|
Hi,
SQL CE doesn't have a timestamp type so there no "obvious" mapping here. You can try to map Timestamp to Binary(8), but new rows won't have new timestamps. You have to do it manually in your code with SQL CE.
Francois YACOB.
|
|
|
|
|
Hy,
this tool ist very good, but I have a problem with the primery keys.
In all of my tables are one colum with an ID. This ID is the primerykey of this table.
If I make an import the ID´s are all minus 1.
Have anybody a solution for me?
|
|
|
|
|
I am trying to copy a 2 GB file to SQL server Compact. The program keeps on reporting an "Out of Memory" exception. There is one large field (ntext type) The file was originally an access database with a memo field that was converted to SQL server express 2008. Program seems to work well except for this problem. Any suggestions would be appreciated.
|
|
|
|
|
Hi
this tool is really great, i just found out it doesn't work with NVARCHAR(MAX) columns. To make it works, you need to add one more case in WizardForm.cs which can look like this (works for me):
foreach (Column col in tbl.Columns)
{
if (colIdx > 0)
sb.Append(", ");
sb.Append("[").Append(col.Name).Append("]").Append(" ");
int max = 0;
switch (col.DataType.SqlDataType)
{
case SqlDataType.NVarCharMax:
max = 4000;
col.DataType = new DataType(SqlDataType.NVarChar);
col.DataType.MaximumLength = max;
break;
I know that in SQL Server Compact 3.5 the maximum value of NVARCHAR data type is 4000, so I set it to that value, I'm not sure about other versions.
Anyway, thanks again for this great tool!
|
|
|
|
|
|
I was having problems generating ADO Entity model from a ce db generated with this excelent tool:
"error 6003: The item with identity 'Id' already exists in the metadata collection."
I made the following change:
WizardForm
Line 532
sb.Append("ALTER TABLE [").Append(tbl.Name).Append("] ADD CONSTRAINT PK_");
to
sb.Append("ALTER TABLE [").Append(tbl.Name).Append("] ADD CONSTRAINT PK_" + tbl.Name);
Now it works great !
Thanks!
|
|
|
|
|
Thanks for your modification, it helps me a lot !
Of course, in your patch, we can comment the following loop :
sb.Append("ALTER TABLE [").Append(tbl.Name).Append("] ADD CONSTRAINT PK_" + tbl.Name);
//create the constraint name
/* Francois : Not need to append the primary field name to the constraint !
for (int k = 0; k < pKeys.Count; k++)
{
if (k > 0)
sb.Append("_");
sb.Append(pKeys[k]);
}
*/
Best regards,
François.
|
|
|
|
|
|
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) <br />
{<br />
foreach (Schema schema in db.Schemas)<br />
...<br />
}
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;<br />
if (tableCtrl1.SchemaName == "")<br />
tbl = sourceDb.Tables[tblName];<br />
else<br />
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:<br />
col.DataType = new DataType(SqlDataType.DateTime);<br />
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.
|
|
|
|