private static void LoadDataSource()
        {
            var dbPath = SqlLoader.GetDatabaseDirectory(null);
            var loader = new SqlLoader();

            loader.SetDatabaseEngine("(localdb)\\MSSQLLocalDB");
            loader.AddScript("instnwdb.sql");
            loader.AddScriptArgument("SqlSamplesDatabasePath", dbPath);
            loader.Execute(dbPath);
        }
Exemple #2
0
        private static void LoadDataSource()
        {
            var dbPath = SqlLoader.GetDatabaseDirectory(null);
            var loader = new SqlLoader();

            loader.SetDatabaseEngine("(localdb)\\MSSQLLocalDB");
            loader.AddScript("instnwdb.sql");
            loader.AddScriptArgument("SqlSamplesDatabasePath", dbPath);

            // Length of database name in SQLServer cannot exceed 128.
            var dbNamePrefix = dbPath;

            if (dbNamePrefix.Length > 100)
            {
                dbNamePrefix = dbNamePrefix.Substring(dbNamePrefix.Length - 100);
                dbNamePrefix = dbNamePrefix.Substring(dbNamePrefix.IndexOf('\\') + 1);
            }

            loader.AddScriptArgument("SqlDBNamePrefix", dbNamePrefix);
            loader.Execute(dbPath);
        }