Click here to Skip to main content
Click here to Skip to main content

SQL Server to SQL Server Compact Edition Database Copy Utility

By , 26 Jun 2008
 

UPDATE

Please download the latest version of this tool from JohnnyCantCode.com. I have updated this utility based on some feedback from users.

I added the ability to select the schema you wish to copy. For most databases, this will simply be "dbo".

I fixed a bug where the application did not recognize a valid version of "System.Data.SqlServerCe.dll".

Introduction

This utility will copy the schema and data from a normal SQL Server 2000/2005 database and export it to a SQL Server Compact Edition database. The tool supports version 3.1 or 3.5 of SQL Server Compact Edition.

Background

I was working on a mobile application and needed an easy way to manage the table relationships and indexes without having to resort to scripting. I was familiar with using SQL Server Management Studio so I decided that I would write a utility that converted a normal SQL Server database to a mobile database. This way, I could continue using the tool I normally use to create and maintain my databases.

Using the Code

Feel free to take a look at the code and offer your most gracious comments. The application uses a wizard to walk you through converting a database. I have also included a normal WINFORM that also does the conversion, but I stopped development on this in lieu of the wizard, so the form is incomplete. I will be maintaining this code and writing more about it on my blog at www.JohnnyCantCode.com. You can find the original post here.

Points of Interest

This utility will copy Indexes, Primary Keys, Foreign Keys, Table structure and data. SQL Server Compact Edition does not have support for Views, Triggers nor Stored Procedures, therefore this utility does not copy these.

History

  • 1.0 Initial release

License

This article, along with any associated source code and files, is licensed under The BSD License

About the Author

johnnycantcode
Software Developer (Senior) Gologic Tech LLC.
United States United States
Member
I work as an independent software architect and senior developer. I have worked on many large enterprise projects as well as small single user applications.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralGreat tool - after some manual changes :-)memberdolbysys18 Feb '13 - 21:16 
I was searching for a tool like this for some time and when I finally found this here, I was a little bit disappointed that I wasn't able to compile it in VS2010/VS2012.
 
After the following changes it worked like a charm:
  • Remove unavailable projects
  • Remove unavailable referenced assemblies (Microsoft.SqlServer.*)
  • Adding references to Microsoft.SqlServer.* assemblies
    located in %ProgramFiles%\Microsoft SQL Server\100\SDK\Assemblies
  • Change the implementation of SelectMobileAssembliesDialog.Check35version() as described in comment:
    private bool Check35version(string path)
    {
      if (String.IsNullOrEmpty(path))
        return false;
     
      FileVersionInfo ver = FileVersionInfo.GetVersionInfo(path);
      if (ver.FileVersion == "3.5.8080.0")
      {
        _Ver35Valid = true;
        return true;
      }
      else
      {
        _Ver35Valid = false;
        return false;
      }
    }
See also this comment
 
Thanks for this piece of work Thumbs Up | :thumbsup:
GeneralRe: Great tool - after some manual changes :-)memberpmiossec27 Feb '13 - 12:45 
I have done all these changes (and remove version checking do be more open) here :
https://github.com/pmiossec/SQL2SQLCompact[^]
GeneralRe: Great tool - after some manual changes :-)memberronan_mc25 Apr '13 - 13:07 
I downloaded the code from github but I'm getting namespace not found for 'Server' and 'Database' in
SourceCtrl.cs, TableCtrl.cs
GeneralRe: Great tool - after some manual changes :-)memberpmiossec28 Apr '13 - 1:43 
I think, you should have a problem with the references included with the project. Verify (and if needed update) the reference to the file "C:\Program Files\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.SqlServer.Smo.dll"
Questiongeht nicht!memberMember 250914025 Jan '13 - 4:56 
nach konvertierung in VS.2012 lässt sich das Programm nicht starten Frown | :-(
AnswerRe: geht nicht!memberdolbysys18 Feb '13 - 21:20 
Nach ein paar kleinen Änderungen kann man das Projekt auch mit VS2010 / VS2012 starten:
See this comment[^]
QuestionMdf----_> sdf and sdf ----> mdfmembercjgallardo9629 Oct '12 - 3:03 
Hola, una consulta soy nuevo en programación movil y como tal tengo un pequeño problema , tengo una aplicacion de escritorio (sql server 2008 (mdf) y visual basic 2008) y deseo leer desde mi dispositivo movil algunas consultas, pero como mi movil tiene bd en extension sdf....entonces como hago que cuando consulte al servidor de mdf me convierta en simultaneo sdf y cunado quiero hacer una transaccion desde mi celular igual lo guarde como mdf.
Disculpe las molestias y ansioso de sus sabias respuestas.
Atte .-
C. Javier Del Aguila Gallardo
Questionasm.GetType("System.Data.SqlServerCe.SqlCeEngine"); returns nullmemberbradut15 Oct '12 - 11:25 
Hi,
Thank you for this application: it solves an important need, and I hope i will also be able to use it as wellSmile | :)
 
Unfortunately, I have a problem:
In WizardForm.cs, line 381,
Type type = asm.GetType("System.Data.SqlServerCe.SqlCeEngine");
, I get a null value when I try to copy a database from MS SQL 2008 Express to Compact Edition 3.5 SP2

Could anyone suggest a fix for this please?
AnswerRe: asm.GetType("System.Data.SqlServerCe.SqlCeEngine"); returns nullmemberJeff Wharton2 Jan '13 - 18:01 
The description of the application clearly states that it works for SQL Server 7.0, SQL Server 2000 and SQL Server 2005. This is why you are getting this error. You will need to upgrade the Microsoft.SQLServer.* references to use SQL Server 2008 assemblies.
QuestionMy vote of 5memberSPI24 Aug '12 - 7:20 
Great. Thanks.
GeneralMy vote of 5memberBig D27 Apr '12 - 9:40 
A big Thanks
GeneralMy vote of 5membermanoj kumar choubey17 Apr '12 - 2:21 
Nice
GeneralMy vote of 5memberfootnote9 Sep '11 - 8:28 
With a few changes as suggested by earlier commenters, this makes up an automation tool that saves a lot of time. Thanks!
QuestionIs there anyone able to make it work with SQL Server 2008 R2?memberEhsan.thabit21 Jun '11 - 8:14 
Great program
GeneralSupport for Compact edition v3.5 sp2memberjcgk_7713 Apr '11 - 2:32 
Hi
 
I just add new version number, so that this program could be able to support SQL Server Compact Edition V3.5 Sp2.
 
Just open the SQLToSQLCompactCopy-source\Dialogs\SelectMobileAssembliesDialog.cs and replace the current "Check35version()" function with
 
private bool Check35version(string path)
{
if (String.IsNullOrEmpty(path))
return false;
 
FileVersionInfo ver = FileVersionInfo.GetVersionInfo(path);
if (ver.FileVersion == "3.5.8080.0")
{
_Ver35Valid = true;
return true;
}
else
{
_Ver35Valid = false;
return false;
}
}
GeneralRe: Support for Compact edition v3.5 sp2memberMember 849633121 Mar '12 - 9:40 
Or rather support for both versions:
---8<---
private bool Check35version(string path)
{
    if (String.IsNullOrEmpty(path))
       return false;
 
    FileVersionInfo ver = FileVersionInfo.GetVersionInfo(path);
    if (ver.FileVersion == "3.5.8080.0" ||
        ver.FileVersion == "3.5.5386.0")
    {
       _Ver35Valid = true;
       return true;
    }
---8<---
Default locateion for: System.Data.SqlServerCe.dll
= C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Desktop
= C:\Program Files\Microsoft SQL Server Compact Edition\v4.0\Desktop
 
Also a tweek for the References for SQL Server 2012 Express
make ref to theise .DLL's
C:\Program Files\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.SqlServer.ConnectionInfo.dll
C:\Program Files\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.SqlServer.Management.Sdk.Sfc.dll
C:\Program Files\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.SqlServer.Smo.dll
C:\Program Files\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.SqlServer.SqlEnum.dll
regards Big Grin | :-D
QuestionJohnny Can't Code?memberMember 78058094 Apr '11 - 5:43 
johnnycantcode.com appears to have no content... anywhere on the site...
 
Why does the solution reference projects GLT.Common and GLT.Licensing which are not included, and do not appear to be required?
Generalgetting error just-in-time (JIT) debugging instead of this dialog boxmemberpsnlakshmi30 Oct '10 - 1:40 
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:///C:/WINDOWS/Microsoft.NET/Framewo

rk/v2.0.50727/mscorlib.dll
----------------------------------------
GLT.SqlCopy
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: 
 
file:///C:/Documents%20and%20Settings/la

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:///C:/WINDOWS/assembly/GAC_MSIL/Sys

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:///C:/WINDOWS/assembly/GAC_MSIL/Sys

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:///C:/WINDOWS/assembly/GAC_MSIL/Sys

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:///C:/WINDOWS/assembly/GAC_MSIL/Acc

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:///C:/WINDOWS/assembly/GAC_MSIL/Sys

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:///C:/WINDOWS/assembly/GAC_MSIL/Sys

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:///C:/WINDOWS/assembly/GAC_MSIL/Mic

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:///C:/WINDOWS/assembly/GAC_MSIL/Mic

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:///C:/WINDOWS/assembly/GAC_32/Syste

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:///C:/WINDOWS/assembly/GAC_MSIL/Mic

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:///C:/WINDOWS/assembly/GAC_32/Syste

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:///C:/WINDOWS/assembly/GAC_32/Syste

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:///C:/WINDOWS/assembly/GAC_MSIL/Mic

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:///C:/WINDOWS/assembly/GAC_32/Micro

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:///C:/WINDOWS/assembly/GAC_MSIL/Sys

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[^]
GeneralBad Image Format Exceptionmemberi_lonsdale@hotmail.com15 Oct '10 - 22:43 
Hello
 
Great tool if I could get it to work... Sigh | :sigh:
 
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 Smile | :)
Generalproblem with varbinarymemberpgarbo17 Aug '10 - 5:05 
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

GeneralThanksmemberUros Calakovic8 Aug '10 - 2:00 
Great work, thanks.
The bearing of a child takes nine months, no matter
how many women are assigned.

QuestionException where Copying DatabasememberEdgarVegaD14 Jan '10 - 4:36 
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?
AnswerRe: Exception where Copying DatabasememberEdgarVegaD14 Jan '10 - 8:14 
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
AnswerRe: Exception where Copying Databasememberdille421 May '10 - 3:34 
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[^]
GeneralGETUTCDATE() & Multi-Column Key'smembermichael@merlot.com21 Nov '09 - 4:41 
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))
                        {
                            // SQL Server CE 3.5 does not support function GETUTCDATE()
                            col.DefaultConstraint.Text = col.DefaultConstraint.Text.Replace("(getutcdate())", "(getdate())");
                            string def = col.DefaultConstraint.Text.Replace("((", "(").Replace("))", ")");
 
                            sb.Append(" DEFAULT ").Append(col.DefaultConstraint.Text);
                            //sb.Append(" DEFAULT (1) ");
                        }
 
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.
 
                                    // Check If Multi-Column Key's => Iterate Keys
                                    string createFKSql = String.Empty;
                                    if (sourceDb.Tables[fk.ReferencedTable].Indexes[fk.ReferencedKey].IndexedColumns.Count == 1)
                                    {
                                        // Single PK so use the original string
                                        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)
                                    {
                                        // Multi-Column PK
                                        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)
                                        {
                                            // Separate Columns including the square brackets
                                            // to identify each referenced column.
                                            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)
                                    {
                                        // Added square brackets to identify each column.
                                        if (sbFk.Length > 0)
                                            sbFk.Append("], [");
 
                                        sbFk.Append(col.Name);
                                    }
 
But, as I said: only minor issues on a great tool Smile | :)
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

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 26 Jun 2008
Article Copyright 2008 by johnnycantcode
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid