|
HI
I´m trying to copy a SQL Server 2005 DB to a SQL Compact DB using the this tool, everything goes fine but when I do the last step I get this error
See the end of this message for details
on invoking
just-in-time (JIT) debugging instead of
this dialog box.
************** Exception Text
**************
System.Reflection.TargetInvocationExcept
ion: Exception has been thrown by the
target of an invocation. --->
System.ArgumentException: Invalid value
for key 'locale identifier'. --->
System.FormatException: Input string was
not in a correct format.
at
System.Number.StringToNumber(String str,
NumberStyles options, NumberBuffer&
number, NumberFormatInfo info, Boolean
parseDecimal)
at System.Number.ParseInt32(String s,
NumberStyles style, NumberFormatInfo
info)
at
System.Data.SqlServerCe.ConStringUtil.Se
tIntType(String value, String key)
--- End of inner exception stack
trace ---
at
System.Data.SqlServerCe.ConStringUtil.Se
tIntType(String value, String key)
at
System.Data.SqlServerCe.ConStringUtil.Se
tLocale(Hashtable table)
at
System.Data.SqlServerCe.ConStringUtil.Ve
rifyValues(Hashtable values)
at
System.Data.SqlServerCe.ConStringUtil.Pa
rseConnectionString(String&
connectionString)
at
System.Data.SqlServerCe.SqlCeEngine.set_
LocalConnectionString(String value)
at
System.Data.SqlServerCe.SqlCeEngine..cto
r(String connectionString)
--- End of inner exception stack
trace ---
at
System.RuntimeMethodHandle._InvokeConstr
uctor(Object[] args, SignatureStruct&
signature, IntPtr declaringType)
at
System.RuntimeMethodHandle.InvokeConstru
ctor(Object[] args, SignatureStruct
signature, RuntimeTypeHandle
declaringType)
at
System.Reflection.RuntimeConstructorInfo
.Invoke(BindingFlags invokeAttr, Binder
binder, Object[] parameters, CultureInfo
culture)
at
System.RuntimeType.CreateInstanceImpl(Bi
ndingFlags bindingAttr, Binder binder,
Object[] args, CultureInfo culture,
Object[] activationAttributes)
at
System.Activator.CreateInstance(Type
type, BindingFlags bindingAttr, Binder
binder, Object[] args, CultureInfo
culture, Object[] activationAttributes)
at GLT.SqlCopy.WizardForm.DoCopy()
at
GLT.SqlCopy.WizardForm.UpdateWizard()
at
GLT.SqlCopy.WizardForm.btnNext_Click(Obj
ect sender, EventArgs e)
at
System.Windows.Forms.Control.OnClick(Eve
ntArgs e)
at
System.Windows.Forms.Button.OnClick(Even
tArgs e)
at
System.Windows.Forms.Button.OnMouseUp(Mo
useEventArgs mevent)
at
System.Windows.Forms.Control.WmMouseUp(M
essage& m, MouseButtons button, Int32
clicks)
at
System.Windows.Forms.Control.WndProc(Mes
sage& m)
at
System.Windows.Forms.ButtonBase.WndProc(
Message& m)
at
System.Windows.Forms.Button.WndProc(Mess
age& m)
at
System.Windows.Forms.Control.ControlNati
veWindow.OnMessage(Message& m)
at
System.Windows.Forms.Control.ControlNati
veWindow.WndProc(Message& m)
at
System.Windows.Forms.NativeWindow.Callba
ck(IntPtr hWnd, Int32 msg, IntPtr
wparam, IntPtr lparam)
************** Loaded Assemblies
**************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433
(REDBITS.050727-1400)
CodeBase:
file:
rk/v2.0.50727/mscorlib.dll
----------------------------------------
GLT.SqlCopy
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase:
file:
xmi/Desktop/SQL2005%20express%20ToSQLCom
pact%20Convert/GLT.SqlCopy.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433
(REDBITS.050727-1400)
CodeBase:
file:
tem.Windows.Forms/2.0.0.0__b77a5c561934e
089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433
(REDBITS.050727-1400)
CodeBase:
file:
tem/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433
(REDBITS.050727-1400)
CodeBase:
file:
tem.Drawing/2.0.0.0__b03f5f7f11d50a3a/Sy
stem.Drawing.dll
----------------------------------------
Accessibility
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433
(REDBITS.050727-1400)
CodeBase:
file:
essibility/2.0.0.0__b03f5f7f11d50a3a/Acc
essibility.dll
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433
(REDBITS.050727-1400)
CodeBase:
file:
tem.Configuration/2.0.0.0__b03f5f7f11d50
a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433
(REDBITS.050727-1400)
CodeBase:
file:
tem.Xml/2.0.0.0__b77a5c561934e089/System
.Xml.dll
----------------------------------------
Microsoft.SqlServer.Smo
Assembly Version: 9.0.242.0
Win32 Version: 9.00.4035.00
CodeBase:
file:
rosoft.SqlServer.Smo/9.0.242.0__89845dcd
8080cc91/Microsoft.SqlServer.Smo.dll
----------------------------------------
Microsoft.SqlServer.ConnectionInfo
Assembly Version: 9.0.242.0
Win32 Version: 9.00.4035.00
CodeBase:
file:
rosoft.SqlServer.ConnectionInfo/9.0.242.
0__89845dcd8080cc91/Microsoft.SqlServer.
ConnectionInfo.dll
----------------------------------------
System.Data
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433
(REDBITS.050727-1400)
CodeBase:
file:
m.Data/2.0.0.0__b77a5c561934e089/System.
Data.dll
----------------------------------------
Microsoft.SqlServer.SmoEnum
Assembly Version: 9.0.242.0
Win32 Version: 9.00.4035.00
CodeBase:
file:
rosoft.SqlServer.SmoEnum/9.0.242.0__8984
5dcd8080cc91/Microsoft.SqlServer.SmoEnum
.dll
----------------------------------------
System.Transactions
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433
(REDBITS.050727-1400)
CodeBase:
file:
m.Transactions/2.0.0.0__b77a5c561934e089
/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433
(REDBITS.050727-1400)
CodeBase:
file:
m.EnterpriseServices/2.0.0.0__b03f5f7f11
d50a3a/System.EnterpriseServices.dll
----------------------------------------
Microsoft.SqlServer.SqlEnum
Assembly Version: 9.0.242.0
Win32 Version: 9.00.4035.00
CodeBase:
file:
rosoft.SqlServer.SqlEnum/9.0.242.0__8984
5dcd8080cc91/Microsoft.SqlServer.SqlEnum
.dll
----------------------------------------
Microsoft.SqlServer.BatchParser
Assembly Version: 9.0.242.0
Win32 Version: 2005.090.4035.00
CodeBase:
file:
soft.SqlServer.BatchParser/9.0.242.0__89
845dcd8080cc91/Microsoft.SqlServer.Batch
Parser.dll
----------------------------------------
System.Data.SqlServerCe
Assembly Version: 9.0.242.0
Win32 Version: 3.0.5300.0
CodeBase:
file:
tem.Data.SqlServerCe/9.0.242.0__89845dcd
8080cc91/System.Data.SqlServerCe.dll
----------------------------------------
************** JIT Debugging
**************
To enable just-in-time (JIT) debugging,
the .config file for this
application or computer (machine.config)
must have the
jitDebugging value set in the
system.windows.forms section.
The application must also be compiled
with debugging
enabled.
For example:
<configuration>
<system.windows.forms
jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any
unhandled exception
will be sent to the JIT debugger
registered on the computer
rather than be handled by this dialog
box.
Help me any body?
Note: i downlod the SQLToSQLCompactCopy.zip from
http://www.johnnycantcode.com/page/SQL-Server-to-SQL-Server-Compact-Edition-Database-Copy.aspx[^]
|
|
|
|
|
Hello
Great tool if I could get it to work...
I get the following exeption thrown when it tries to create the database:
Could not load file or assembly 'file:///C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\sqlcecompact35.dll' or one of its dependencies. The module was expected to contain an assembly manifest.
I am running it on a Vista Home machine with Visual Studio 2008 pro. I have SQL Express 2005 and SQL CE 3.5 sp2
Hope you can help!
Many thanks in advance.
Ian
|
|
|
|
|
There's a small problem with varbinary columns. They are created with length 1. Simple change in wizardForm.cs @472 fixes this issue:
if (datatype == SqlDataType.NVarChar || datatype == SqlDataType.NChar || datatype == SqlDataType.VarBinary)
sb.Append(" (").Append(col.DataType.MaximumLength.ToString()).Append(") ");
Anyway, software is great! Thanks, Johnny!
garbo
|
|
|
|
|
Great work, thanks.
The bearing of a child takes nine months, no matter
how many women are assigned.
|
|
|
|
|
Hello
I´m trying to copy a SQL Server DB to a SQL Compact DB using the SQL Server to SQL Compact Edition DB Copy, everything goes fine but when I do the last step (Finish) I get an error that says:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Invalid value for key 'locale identifier'. ---> System.FormatException: Input string was not in a correct format.
The "Summary & Review" window shows my connection string that is:
SQL Server Compact Edition Connection String:
Data Source='C:\';LCID=myuser;Password=mypassword;Encrypt=FALSE;SSCE:Max Database Size=4091;
To complement the information, the source database is not local.
Any ideas?
|
|
|
|
|
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.
|
|
|
|
|