Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Use MS SQL Ce Compact

Discussion in 'Scripting' started by spootymilk, Jul 13, 2018.

  1. spootymilk

    spootymilk

    Joined:
    Jun 9, 2017
    Posts:
    18
    Hi,

    I would like to use MSSQL compact in my project. I need to use it because it will interact with an existing application that use this type of database.

    I've imported the system.data.sqlserveurce.dll in the plugin folder. But when i'm trying to use it throw me an external exception without any further details.
    My code :

    Code (CSharp):
    1.  
    2. void CreateDatabase()
    3.     {
    4.        
    5.         string connString = "Data Source = 'C:/ProgramData/Aurissimo/HearingSpace/HearingSpaceData.sdf'; LCID = 1033; Password = 'hyperboss'";
    6.         try
    7.         {
    8.         SqlCeEngine engine = new SqlCeEngine (connString);
    9.         engine.CreateDatabase ();
    10.         engine.Dispose ();
    11.         }
    12.         catch (SqlCeException e)
    13.         {
    14.             Debug.LogError (e.Message);
    15.         }
    16.     }
    The error happens at the line : SqlCeEngine engine = new SqlCeEngine (connString);

    Is there someone that have already use it in a unity project ?