none
Convert sql compact database to sql server express

    Question

  • How can i convert SQL compact database to a sql server express database with minimum deployment by using coding?
    Monday, September 02, 2013 12:03 PM

Answers

  • Get the source code, and retarget and recompile to 3.5? Or use the older API, and then use sqlcmd to execute the generated script against the SQL Server Express database.

    Please mark as answer, if this was it. Visit my <a href="http://erikej.blogspot.com"> SQL Server Compact blog</a>

    Wednesday, September 04, 2013 9:39 AM
    Moderator

All replies

  • You can use this (+ maybe some code to create the empty database in SQL Server Express) http://erikej.blogspot.dk/2013/03/sql-server-compact-code-snippet-of-week_8.html

    Please mark as answer, if this was it. Visit my <a href="http://erikej.blogspot.com"> SQL Server Compact blog</a>

    Monday, September 02, 2013 12:24 PM
    Moderator
  • You can use this (+ maybe some code to create the empty database in SQL Server Express) http://erikej.blogspot.dk/2013/03/sql-server-compact-code-snippet-of-week_8.html

    Please mark as answer, if this was it. Visit my <a href="http://erikej.blogspot.com"> SQL Server Compact blog</a>

    From where i will get the dll file for ErikEJ.SqlCeScripting?
    Monday, September 02, 2013 12:40 PM
  • Follow the link in the blog post to here: https://exportsqlce.codeplex.com/releases/view/80551

    Please mark as answer, if this was it. Visit my <a href="http://erikej.blogspot.com"> SQL Server Compact blog</a>

    Monday, September 02, 2013 12:49 PM
    Moderator
  • After adding references i am getting error

    Error 5 'ErikEJ.SqlCeScripting.IRepository' does not contain a definition for 'ExecuteSqlFile' and no extension method 'ExecuteSqlFile' accepting a first argument of type 'ErikEJ.SqlCeScripting.IRepository' could be found (are you missing a using directive or an assembly reference?)


    Error 2 The type or namespace name 'DB4Repository' could not be found (are you missing a using directive or an assembly reference?)

    Error 3 The type or namespace name 'Generator4' could not be found (are you missing a using directive or an assembly reference?)

    Error 4 The type or namespace name 'ServerDBRepository4' could not be found (are you missing a using directive or an assembly reference?)

    Monday, September 02, 2013 1:04 PM
  • Add a reference to System.Data.SqlServerCe.dll,  assembly version 3.5.1.0

    Please mark as answer, if this was it. Visit my <a href="http://erikej.blogspot.com"> SQL Server Compact blog</a>

    Monday, September 02, 2013 1:12 PM
    Moderator
  • Add a reference to System.Data.SqlServerCe.dll,  assembly version 3.5.1.0

    Please mark as answer, if this was it. Visit my <a href="http://erikej.blogspot.com"> SQL Server Compact blog</a>

    That reference already added. Is there any project showing this example which i can download?
    Monday, September 02, 2013 1:20 PM
  • Sorry, the sample is for 4.0, use DBRepository instead of DB4Repository, Generator instead Generator4 etc.

    Please mark as answer, if this was it. Visit my <a href="http://erikej.blogspot.com"> SQL Server Compact blog</a>

    Monday, September 02, 2013 1:24 PM
    Moderator
  • I am still getting error

     'ErikEJ.SqlCeScripting.IRepository' does not contain a definition for 'ExecuteSqlFile' and no extension method 'ExecuteSqlFile' accepting a first argument of type 'ErikEJ.SqlCeScripting.IRepository' could be found (are you missing a using directive or an assembly reference?)

    Should i change ExecuteSqlFile to ExecuteSql ?

    When i used ExecuteSql  the tables not created in the database in sql express.I am using sql server 2008 r2.

    But script generated was proper.

    Please help

    Monday, September 02, 2013 2:34 PM
  • You need to reference ISqlCeScripting.dll and SqlCeScripting.dll.  (as I mention in this blog post, that I Refer to from the one above: http://erikej.blogspot.dk/2013/03/sql-server-compact-code-snippet-of-week.html Actually, the best way to get all dll and references installed, if you are using SQL CE 4.0 is to add the SqlCeScripting NuGet package to your project. I will update the blog post I mention in this reply with that info.

    Please mark as answer, if this was it. Visit my <a href="http://erikej.blogspot.com"> SQL Server Compact blog</a>


    Monday, September 02, 2013 4:08 PM
    Moderator
  • I have got from SqlCeScripting after installing ExportSqlCE_Addin_3.5.2.0.zip from this link

     But where i can get SqlCeScripting40.dll? Is it supported in Windows XP?

    Also when i used references for comapct 3.5 as u said before i am getting problem for ExecuteSqlFile  command . So i change it to ExecuteSql . But it will not work(Script generated will not run against sql express database).But script created was proper.

    Tuesday, September 03, 2013 5:22 AM
  • I suggest you read the instructions on the download page, rather than simply download the first available file. You need to download  SqlCeScripting.3.5.2.32.zip And you do not need SqlCeScripting40.dll for anything, it is for use with SQL Server Compact 4.0. See the instructions here (that I have linked previously already: http://erikej.blogspot.dk/2013/03/sql-server-compact-code-snippet-of-week.html ) 

    And yes, the API works on Windows XP SP3 and all later desktop platforms. (Not Windows RT)


    Please mark as answer, if this was it. Visit my <a href="http://erikej.blogspot.com"> SQL Server Compact blog</a>

    Tuesday, September 03, 2013 7:12 AM
    Moderator
  • Both ExportSqlCE_Addin_3.5.2.0.zip and SqlCeScripting.3.5.2.32.zip contain those files. But i downloaded library files from SqlCeScripting.3.5.2.32.zip as you mentioned. But should i register those dll? I am not able to add them to my project.If i add then also it is not used. See below image.

    If i download ExportSqlCE_Addin_3.5.2.0.zip i get exe. after installing it i can add the dll in my project. if i do this i get error for ExecuteSqlFile . 

    This is the problem i am facing. So please help.I dont know what else i have to do.

    Wednesday, September 04, 2013 6:01 AM
  • You should use the files from SqlCeScriptuing.Zip, as they are newer and implement ExecuteSqlFile.

    1: Extract the files from SqlCeScripting.zip

    2: Place them in your project folder, for example in a lib sub folder

    3: Reference ISqlCeScripting, SqlCeScripting, and the 3 QiuckGrap dll files

    4: Done


    Please mark as answer, if this was it. Visit my <a href="http://erikej.blogspot.com"> SQL Server Compact blog</a>

    Wednesday, September 04, 2013 6:40 AM
    Moderator
  • If i add the reference by keeping files in a folder inside project then error will come as i shown in my last reply.(please see image in last reply. An yellow warning image on references). What is the reason for this?
    Wednesday, September 04, 2013 8:05 AM
  • The yellow icon indicates that the file cannot be found. Remove and readd the reference, and browse to the correct file  location.

    Please mark as answer, if this was it. Visit my <a href="http://erikej.blogspot.com"> SQL Server Compact blog</a>

    Wednesday, September 04, 2013 8:49 AM
    Moderator
  • No. i am selecting proper files by browsing it. Please see my sample project here
    Wednesday, September 04, 2013 9:15 AM
  • Thanks for sharing your test project.

    As stated here: https://exportsqlce.codeplex.com/documentation the ExportSqlCe libraries require .NET 4.0 or later, and your solution is created with VS 2008 using .NET 3.5, so that wont work. Suggest you upgrade your development environment to  VS 2012 C# Express (or just VS 2012 C# Express).



    Please mark as answer, if this was it. Visit my <a href="http://erikej.blogspot.com"> SQL Server Compact blog</a>

    Wednesday, September 04, 2013 9:23 AM
    Moderator
  • ok. i didn't notice that 'System requirement' tab in the website. But is there any other method which work in .net 3.5 target project? Please suggest if any.
    Wednesday, September 04, 2013 9:33 AM
  • Get the source code, and retarget and recompile to 3.5? Or use the older API, and then use sqlcmd to execute the generated script against the SQL Server Express database.

    Please mark as answer, if this was it. Visit my <a href="http://erikej.blogspot.com"> SQL Server Compact blog</a>

    Wednesday, September 04, 2013 9:39 AM
    Moderator