当前位置: 首页>>代码示例>>C#>>正文


C# SqlCeEngine.Dispose方法代码示例

本文整理汇总了C#中SqlCeEngine.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# SqlCeEngine.Dispose方法的具体用法?C# SqlCeEngine.Dispose怎么用?C# SqlCeEngine.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SqlCeEngine的用法示例。


在下文中一共展示了SqlCeEngine.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyLM

        /// <summary>
        /// Copies the LM.
        /// </summary>
        /// <returns></returns>
        /// <remarks>Documented by Dev07, 2009-05-20</remarks>
        public static bool CopyLM(string source, string destination)
        {
            try
            {
                string filename = destination;
                if (File.Exists(filename))
                {
                    int i = 0;
                    while (File.Exists(filename.Replace(".mlm", "_" + i + ".mlm"))) i++;
                    filename = filename.Replace(".mlm", "_" + i + ".mlm");
                }

                string sourceConString = MSSQLCEConn.GetFullConnectionString(source);
                string desConString = MSSQLCEConn.GetFullConnectionString(filename);
                SqlCeEngine engine = new SqlCeEngine(sourceConString);
                engine.Compact(desConString);
                engine.Dispose();
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.ToString());
                return false;
            }
            return true;
        }
开发者ID:Stoner19,项目名称:Memory-Lifter,代码行数:30,代码来源:Library.cs

示例2: RunApplication

		public void RunApplication(string[] args)
		{
			// example command line args: 
			// ClearCanvas.Dicom.DataStore.SetupApplication.Application "<TrunkPath>\Dicom\DataStore\AuxiliaryFiles\empty_viewer.sdf" "<TrunkPath>\Dicom\DataStore\AuxiliaryFiles\CreateTables.clearcanvas.dicom.datastore.ddl"

			string databaseFile = args[0];
			string scriptFile = args[1];

			File.Delete(databaseFile);

			string connectionString = String.Format("Data Source=\"{0}\"", databaseFile);

			SqlCeEngine engine = new SqlCeEngine(connectionString);
			engine.CreateDatabase();
			engine.Dispose();

			StreamReader reader = new StreamReader(scriptFile);
			string scriptText = reader.ReadToEnd();
			reader.Close();

			SqlCeConnection connection = new SqlCeConnection(connectionString);
			connection.Open();

			SqlCeTransaction transaction = connection.BeginTransaction();
			SqlCeCommand command = new SqlCeCommand();
			command.Connection = connection;
			command.CommandText = scriptText;
			command.ExecuteNonQuery();

			transaction.Commit();
			connection.Close();

		}
开发者ID:khaha2210,项目名称:radio,代码行数:33,代码来源:Application.cs

示例3: Main

        static void Main(string[] args)
        {
            var databaseFilePath = @"c:\code\achlookup\db.sdf";
            var connectionString = String.Format("Data Source={0}", databaseFilePath);
            var filePath = @"c:\code\achlookup\fpddir.txt";

            if(File.Exists(databaseFilePath))
            {
                File.Delete(databaseFilePath);
            }

            var engine = new SqlCeEngine(connectionString);
            engine.CreateDatabase();
            engine.Dispose();

            using(var connection = new SqlCeConnection(connectionString))
            {
                connection.Open();
                var command = connection.CreateCommand();
                command.CommandText = @"
            CREATE TABLE Banks (RoutingNumber nvarchar(10), Name nvarchar(255))
            ";
                command.ExecuteNonQuery();
                connection.Close();
            }

            var sql = @"
            INSERT INTO Banks(RoutingNumber,Name) VALUES(@RoutingNumber,@BankName)
            ";

            using (var connection = new SqlCeConnection(connectionString))
            {
                connection.Open();
                var command = connection.CreateCommand();
                command.CommandText = sql;
                command.Parameters.Add("@RoutingNumber", SqlDbType.NVarChar);
                command.Parameters.Add("@BankName", SqlDbType.NVarChar);

                foreach (var line in File.ReadLines(filePath))
                {
                    BankRecord record;
                    record.RoutingNumber = line.Substring(0, 9);
                    record.Name = line.Substring(27, 36);

                    command.Parameters["@RoutingNumber"].Value = record.RoutingNumber;
                    command.Parameters["@BankName"].Value = record.Name;

                    command.ExecuteNonQuery();
                }
            }

            Console.WriteLine("All DONE :)");
            Console.ReadLine();
        }
开发者ID:chrisortman,项目名称:AchLookup,代码行数:54,代码来源:Program.cs

示例4: CompactDatabase

 public static void CompactDatabase()
 {
     string src     = ConnectionParamter;
     string dest    = ConnectionParamter+".tmp";
     // Initialize SqlCeEngine object.
     SqlCeEngine engine = new SqlCeEngine("Data Source = " + src);
     try {
        //engine.Repair("Data Source = " + src, RepairOption.DeleteCorruptedRows);
         engine.Compact("Data Source = " + dest);
         engine.Dispose();
         File.Delete(src);
         File.Move(dest, src);
     } catch(SqlCeException e) {
         //Use your own error handling routine.
         //ShowErrors(e);
         CommonUtils.LogError(e.Message,e);
     } finally {
         //Dispose of the SqlCeEngine object.
         engine.Dispose();
     }
 }
开发者ID:mzkabbani,项目名称:cSharpProjects,代码行数:21,代码来源:BackEndUtils.cs

示例5: CreateDatabase

        private static String CreateDatabase()
        {
            String dbPath = String.Format("{0}scanner.sdf", rootPath);
            if (File.Exists(dbPath))
                File.Delete(dbPath);

            String connectionString = String.Format("DataSource=\"{0}\";Max Database Size=3000;", dbPath);
            SqlCeEngine en = new SqlCeEngine(connectionString);
            en.CreateDatabase();
            en.Dispose();

            return connectionString;
        }
开发者ID:iceslab,项目名称:BD2_PROJEKT,代码行数:13,代码来源:DatabaseConnection.cs

示例6: CreateConnection

        public static dynamic CreateConnection(string dbName, IList<string> createTables, IList<string> queries)
        {
            if (File.Exists(dbName))
                File.Delete(dbName);

            var en = new SqlCeEngine("Data Source = " + dbName);
            en.CreateDatabase();
            en.Dispose();
            var conn = new SqlCeConnection("Data Source = " + dbName);
            conn.Open();
            foreach (var comm in createTables.Select(createTable => new SqlCeCommand(createTable, conn)))
            {
                Console.WriteLine("Response: " + comm.ExecuteNonQuery());
            }
            foreach (var query in queries)
            {
                SqlCeCommand cmd = conn.CreateCommand();
                cmd.CommandText = query;
                cmd.ExecuteNonQuery();
            }
            conn.Close();
            return Database.OpenFile(dbName);
        }
开发者ID:rlovino,项目名称:LooxLikeServer,代码行数:23,代码来源:DbUtils.cs

示例7: CreateInitialLocalDB

      //  SqlCeConnection ce = null;

        public void CreateInitialLocalDB(string strConnectionString, bool isCreated)
        {
            try
            {
                strClientConnectionString = strConnectionString;

                // sync = new SqlCeClientSyncProvider(strClientConnectionString);
                clientSyncProvider = new SqlCeClientSyncProvider(strClientConnectionString);
                if (!isCreated)
                {
                    SqlCeEngine clientEngine = new SqlCeEngine(strClientConnectionString);
                    clientEngine.CreateDatabase();
                    clientEngine.Dispose();
                    tblCallTable = CreateCallTable();
                    tblLeadsTable = CreateLeadsTable();
                    tblCallBackTable = CreateCallBackTable();
                }
                else
                {
                    tblCallTable = new SyncTable("Call");
                    tblCallTable.SyncDirection = SyncDirection.UploadOnly;

                    tblLeadsTable = new SyncTable("Leads");
                    tblLeadsTable.SyncDirection = SyncDirection.UploadOnly;

                    tblCallBackTable = new SyncTable("CallBack");
                    tblCallBackTable.SyncDirection = SyncDirection.UploadOnly;
                }
                strClientConnectionString = strConnectionString;

                // sync = new SqlCeClientSyncProvider(strClientConnectionString);

                serverSyncProvider = new DbServerSyncProvider();

                syncAgent = new SyncAgent();
                //  syncAgent.ServerSyncProvider = serverSyncProvider;
                syncAgent.RemoteProvider = serverSyncProvider;

                serverConnection = new SqlConnection(VMuktiInfo.MainConnectionString);
                serverSyncProvider.Connection = serverConnection;
            
                //SqlCommand cmdAnchor = new SqlCommand();
                // cmdAnchor.CommandType = CommandType.Text;
                // cmdAnchor.CommandText = "SELECT @@DBTS";
                // serverSyncProvider.SelectNewAnchorCommand = cmdAnchor;

                // SqlCommand cmdClientId = new SqlCommand();
                // cmdClientId.CommandType = CommandType.Text;
                // cmdClientId.CommandText = "SELECT 1";
                // serverSyncProvider.SelectClientIdCommand = cmdClientId;                 



                //syncAgent.ClientSyncProvider = clientSyncProvider;
                syncAgent.LocalProvider = clientSyncProvider;
                myGroup = new SyncGroup("DialerGroup");
                tblCallTable.SyncGroup = myGroup;
                tblLeadsTable.SyncGroup = myGroup;
                tblCallBackTable.SyncGroup = myGroup;


                //syncAgent.SyncTables.Add(tblCallTable);
                //syncAgent.SyncTables.Add(tblLeadsTable);
                //syncAgent.SyncTables.Add(tblCallBackTable);

                syncAgent.Configuration.SyncTables.Add(tblCallTable);
                syncAgent.Configuration.SyncTables.Add(tblLeadsTable);
                syncAgent.Configuration.SyncTables.Add(tblCallBackTable);

                CallAdapter = new SqlSyncAdapterBuilder();
                CallAdapter.Connection = serverConnection;
                CallAdapter.SyncDirection = SyncDirection.UploadOnly;
                CallAdapter.TableName = "Call";
                CallAdapter.DataColumns.Add("ID");
                CallAdapter.DataColumns.Add("LeadID");
                CallAdapter.DataColumns.Add("CalledDate");
                CallAdapter.DataColumns.Add("ModifiedDate");
                CallAdapter.DataColumns.Add("ModifiedBy");
                CallAdapter.DataColumns.Add("GeneratedBy");
                CallAdapter.DataColumns.Add("StartDate");
                CallAdapter.DataColumns.Add("StartTime");
                CallAdapter.DataColumns.Add("DurationInSecond");
                CallAdapter.DataColumns.Add("DespositionID");
                CallAdapter.DataColumns.Add("CampaignID");
                CallAdapter.DataColumns.Add("ConfID");
                CallAdapter.DataColumns.Add("IsDeleted");
                CallAdapter.DataColumns.Add("CallNote");
                CallAdapter.DataColumns.Add("IsDNC");
                CallAdapter.DataColumns.Add("IsGlobal");
                CallAdapterSyncAdapter = CallAdapter.ToSyncAdapter();
                CallAdapterSyncAdapter.DeleteCommand = null;
                serverSyncProvider.SyncAdapters.Add(CallAdapterSyncAdapter);



                LeadAdapter = new SqlSyncAdapterBuilder();
                LeadAdapter.Connection = serverConnection;
                LeadAdapter.SyncDirection = SyncDirection.UploadOnly;
//.........这里部分代码省略.........
开发者ID:jiangguang5201314,项目名称:VMukti,代码行数:101,代码来源:ClsUserDataService.cs

示例8: GetPersistentLMConnection


//.........这里部分代码省略.........

                    if (LMId < 0)       //Persistent (During Test Run)
                        LMId = AddNewLM(repositoryName, isProtected);

                    ConnectionString = new ConnectionStringStruct(DatabaseType.PostgreSQL, connectionString, LMId);

                    #endregion
                    break;
                case "sqlce":
                    #region SqlCe Tests

                    if (repositoryName == string.Empty)     //Not persistent
                    {
                        repositoryName = MachineName;
                        ConnectionString = new ConnectionStringStruct(DatabaseType.MsSqlCe, TestDicSqlCE, false);
                    }
                    else   //Persistent (During Unit Test)
                    {
                        string persistentPath;
                        persistentPath = Path.GetTempPath() + repositoryName + Helper.EmbeddedDbExtension;
                        cleanupQueue.Enqueue(persistentPath);
                        ConnectionString = new ConnectionStringStruct(DatabaseType.MsSqlCe, persistentPath, false);
                    }

                    if (password != string.Empty)
                    {
                        ConnectionString.ProtectedLm = true;
                        ConnectionString.Password = password;
                    }

                    if (LMId < 0)
                    {
                        string sqlCeConnString = GetFullSqlCeConnectionString(ConnectionString);
                        using (SqlCeEngine clientEngine = new SqlCeEngine(sqlCeConnString))
                        {
                            clientEngine.CreateDatabase();
                            clientEngine.Dispose();
                        }
                        using (SqlCeConnection con = new SqlCeConnection(sqlCeConnString))
                        {
                            con.Open();
                            SqlCeTransaction transaction = con.BeginTransaction();
                            string tmp = Helper.GetMsSqlCeScript();
                            string[] msSqlScriptArray = Helper.GetMsSqlCeScript().Split(';');   //Split the whole DB-Script into single commands (SQL-CE can not execute multiple queries)

                            foreach (string sqlCommand in msSqlScriptArray)
                            {
                                if (sqlCommand.TrimStart(' ', '\r', '\n').StartsWith("--") || sqlCommand.TrimStart(' ', '\r', '\n').Length < 5)
                                    continue;
                                using (SqlCeCommand cmd = con.CreateCommand())
                                {
                                    cmd.CommandText = sqlCommand;
                                    cmd.ExecuteNonQuery();
                                }
                            }

                            int cat_id;
                            using (SqlCeCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = "SELECT id FROM Categories WHERE [email protected]_id;";
                                cmd.Parameters.Add("@cat_id", 1);
                                cat_id = Convert.ToInt32(cmd.ExecuteScalar());
                            }

                            using (SqlCeCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = "INSERT INTO LearningModules (guid, title, categories_id, default_settings_id, allowed_settings_id, licence_key, content_protected, cal_count) " +
                                "VALUES (@guid, @title, @cat_id, @dset, @aset, @lk, @cp, @cals);";
                                cmd.Parameters.Add("@guid", new Guid().ToString());
                                cmd.Parameters.Add("@title", "eDB test title");
                                cmd.Parameters.Add("@cat_id", cat_id);
                                cmd.Parameters.Add("@lk", "ACDED-LicenseKey-DEDAF");
                                cmd.Parameters.Add("@cp", password == string.Empty ? 0 : 1);
                                cmd.Parameters.Add("@cals", 1);
                                cmd.Parameters.Add("@dset", MsSqlCeCreateNewSettings(sqlCeConnString));
                                cmd.Parameters.Add("@aset", MsSqlCeCreateNewAllowedSettings(sqlCeConnString));
                                cmd.ExecuteNonQuery();
                            }
                            using (SqlCeCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = "SELECT @@IDENTITY;";
                                LMId = Convert.ToInt32(cmd.ExecuteScalar());
                            }
                            transaction.Commit();
                        }
                    }
                    ConnectionString.LmId = LMId;
                    #endregion
                    break;
                default:
                    throw new Exception("TestInfrastructure Class: conditions where set which are not applicable to the current db connection infrastructure");
            }

            IUser user;
            if (callback == null)
                user = UserFactory.Create((GetLoginInformation)GetTestUser, ConnectionString, (DataAccessErrorDelegate)delegate { return; }, standAlone);
            else
                user = UserFactory.Create(callback, ConnectionString, (DataAccessErrorDelegate)delegate { return; }, standAlone);
            return user.Open();
        }
开发者ID:Stoner19,项目名称:Memory-Lifter,代码行数:101,代码来源:TestInfrastructure.cs

示例9: AddNewLM

        public int AddNewLM(string guid, int categoryId, string title, string licenceKey, bool contentProtected, int calCount)
        {
            if (!Parent.CurrentUser.ConnectionString.ConnectionString.EndsWith(Helper.EmbeddedDbExtension))
            {
                ConnectionStringStruct css = Parent.CurrentUser.ConnectionString;
                css.ConnectionString += @"\" + title.Replace(@"\", "_") + Helper.EmbeddedDbExtension;
                css.Typ = DatabaseType.MsSqlCe;
                Parent.CurrentUser.ConnectionString = css;
            }
            {
                //replace invalid filename characters
                ConnectionStringStruct css = Parent.CurrentUser.ConnectionString;
                css.ConnectionString = Helper.FilterInvalidFilenameCharacters(css.ConnectionString);
                Parent.CurrentUser.ConnectionString = css;
            }
            if (File.Exists(Parent.CurrentUser.ConnectionString.ConnectionString))
            {
                int i = 1;
                while (File.Exists(Parent.CurrentUser.ConnectionString.ConnectionString.Replace(Helper.EmbeddedDbExtension, "_" + i + Helper.EmbeddedDbExtension))) i++;

                ConnectionStringStruct css = Parent.CurrentUser.ConnectionString;
                css.ConnectionString = css.ConnectionString.Replace(Helper.EmbeddedDbExtension, "_" + i + Helper.EmbeddedDbExtension);
                Parent.CurrentUser.ConnectionString = css;
            }
            if (!Directory.Exists(Path.GetDirectoryName(Parent.CurrentUser.ConnectionString.ConnectionString)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(Parent.CurrentUser.ConnectionString.ConnectionString));
            }
            using (SqlCeEngine clientEngine = new SqlCeEngine("Data Source=" + Parent.CurrentUser.ConnectionString.ConnectionString))
            {
                clientEngine.CreateDatabase();
                clientEngine.Dispose();
            }
            using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser))
            {
                cmd.CommandText = Resources.MsSqlCeDbCreateScript;
                MSSQLCEConn.ExecuteNonQuery(cmd);
            }
            MSSQLCEConn.ApplyIndicesToDatabase(MSSQLCEConn.GetConnection(Parent.CurrentUser));
            int cat_id;
            using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser))
            {
                cmd.CommandText = "SELECT id FROM Categories WHERE [email protected]_id;";
                cmd.Parameters.Add("@cat_id", categoryId);
                cat_id = MSSQLCEConn.ExecuteScalar<int>(cmd).Value;
            }
            using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser))
            {
                cmd.CommandText = "INSERT INTO LearningModules (guid, title, categories_id, default_settings_id, allowed_settings_id, licence_key, content_protected, cal_count) " +
                    "VALUES (@guid, @title, @cat_id, @dset, @aset, @lk, @cp, @cals); SELECT @@IDENTITY;";
                cmd.Parameters.Add("@guid", guid);
                cmd.Parameters.Add("@title", title);
                cmd.Parameters.Add("@cat_id", cat_id);
                cmd.Parameters.Add("@lk", licenceKey);
                cmd.Parameters.Add("@cp", contentProtected);
                cmd.Parameters.Add("@cals", calCount);
                cmd.Parameters.Add("@dset", MsSqlCeSettingsConnector.CreateNewDefaultSettings(Parent));
                cmd.Parameters.Add("@aset", MsSqlCeSettingsConnector.CreateNewAllowedSettings(Parent));

                return MSSQLCEConn.ExecuteScalar<int>(cmd).Value;
            }
        }
开发者ID:Stoner19,项目名称:Memory-Lifter,代码行数:62,代码来源:MsSqlCeDictionariesConnector.cs

示例10: button2_Click

        private void button2_Click(object sender, EventArgs e)
        {
            File.Delete("Test.sdf");
            SqlCeEngine engine = new SqlCeEngine(connString);
            engine.CreateDatabase();
            engine.Dispose();

            try
            {
                if (conn == null)
                {
                    conn = new SqlCeConnection(connString);
                    conn.Open();
                }

                SqlCeCommand cmd = conn.CreateCommand();
                cmd.CommandText = @"CREATE TABLE banklogs (
            idx INT IDENTITY NOT NULL PRIMARY KEY ,
            date DATETIME NOT NULL ,
            category NVARCHAR( 20 ) NOT NULL ,
            name NVARCHAR( 20 ) NOT NULL ,
            expense INT NOT NULL ,
            income INT NOT NULL ,
            bank NVARCHAR( 20 ) NOT NULL ,
            memo NVARCHAR( 100 ) NOT NULL ,
            cat INT
            );";
                cmd.ExecuteNonQuery();
            }
            catch (Exception E)
            {
                MessageBox.Show(E.Message);
                conn.Close();
                conn.Dispose();
                conn = null;
            }
        }
开发者ID:blmarket,项目名称:filehatchery,代码行数:37,代码来源:Form1.cs

示例11: DbCreateDatabase

        protected override void DbCreateDatabase(DbConnection connection, int? timeOut, StoreItemCollection storeItemCollection)
        {
            #region Check arguments

            ADP1.CheckArgumentNull(connection, "Connection");
            ADP1.CheckArgumentNull(storeItemCollection, "StoreItemCollection");

            #endregion

            // Validate that connection is a SqlCeConnection.
            ValidateConnection(connection);

            // We don't support create/delete database operations inside a transaction as they can't be rolled back.
            if (InTransactionScope())
            {
                throw ADP1.CreateDatabaseNotAllowedWithinTransaction();
            }

            if (_isLocalProvider)
            {
                var engine = new SqlCeEngine(connection.ConnectionString);
                engine.CreateDatabase();
                engine.Dispose();
            }
            else
            {
                try
                {
                    Type rdpType;

                    // If we are working with RDP, then we will need to invoke the APIs through reflection.
                    var engine = RemoteProviderHelper.GetRemoteSqlCeEngine(connection.ConnectionString, out rdpType);
                    Debug.Assert(engine != null);

                    // Invoke the required method on SqlCeEngine.
                    var mi = rdpType.GetMethod("CreateDatabase", new[] { typeof(int?) });
                    Debug.Assert(mi != null);

                    // We will pass 'timeout' to RDP, this will be used as timeout period for connecting and executing on TDSServer.
                    mi.Invoke(engine, new object[] { timeOut });
                }
                catch (Exception e)
                {
                    throw e.GetBaseException();
                }
            }

            // Create the command object depending on provider.
            var command = connection.CreateCommand();

            // Create the command texts from StoreItemCollection.
            var commandTextCollection = SqlDdlBuilder.CreateObjectsScript(storeItemCollection, false);

            DbTransaction transaction = null;

            try
            {
                // Open the connection.
                connection.Open();

                // Open a transaction and attach to the command.
                transaction = connection.BeginTransaction();
                command.Transaction = transaction;

                // Execute each statement.
                foreach (var text in commandTextCollection)
                {
                    command.CommandText = text;
                    command.ExecuteNonQuery();
                }

                // Commit the transaction.
                transaction.Commit();
            }
            catch (Exception e)
            {
                if (transaction != null)
                {
                    // Rollback the transaction.
                    transaction.Rollback();
                }

                // Throw IOE with SqlCeException embedded as inner exception.
                throw new InvalidOperationException(EntityRes.GetString(EntityRes.IncompleteDatabaseCreation), e);
            }
            finally
            {
                // Close connection and cleanup objects.
                if (command != null)
                {
                    command.Dispose();
                }
                if (transaction != null)
                {
                    transaction.Dispose();
                }
                if (connection != null)
                {
                    connection.Close();
                }
//.........这里部分代码省略.........
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:101,代码来源:SqlCeProviderServices.cs

示例12: Create

 /// <summary>
 /// Creates a new extension file.
 /// </summary>
 /// <remarks>Documented by Dev07, 2009-07-06</remarks>
 public void Create()
 {
     if (!Directory.Exists(Path.GetDirectoryName(User.ConnectionString.ConnectionString)))
     {
         Directory.CreateDirectory(Path.GetDirectoryName(User.ConnectionString.ConnectionString));
     }
     if (!File.Exists(User.ConnectionString.ConnectionString))
     {
         using (SqlCeEngine clientEngine = new SqlCeEngine("Data Source=" + User.ConnectionString.ConnectionString))
         {
             clientEngine.CreateDatabase();
             clientEngine.Dispose();
         }
     }
     using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(User))
     {
         cmd.CommandText = Resources.MsSqlCeDbCreateScript;
         MSSQLCEConn.ExecuteNonQuery(cmd);
     }
 }
开发者ID:Stoner19,项目名称:Memory-Lifter,代码行数:24,代码来源:ExtensionFile.cs

示例13: createDB

        /**
         *
         * 创建PDA端的数据库,并且初始化数据库。包括出库表,返库表,入库表
         *
         * */
        public bool createDB()
        {
            try
            {
                if (!System.IO.File.Exists(cfg.LocalDBFile))
                {
                    SqlCeEngine ECsqlEngine = new SqlCeEngine(cfg.LocalConnString);
                    ECsqlEngine.CreateDatabase();
                    ECsqlEngine.Dispose();

                    string outLibrary = @"CREATE TABLE OUT_LIBRARY (epc nvarchar(32) NOT NULL,time datetime,person nvarchar(32), salepointcode nvarchar(50))";
                    string backLibrary = @"CREATE TABLE BACK_LIBRARY (epc nvarchar(32) NOT NULL,time datetime, person nvarchar(32))";
                    string inLibrary = @"CREATE TABLE IN_LIBRARY (epc nvarchar(32) NOT NULL,time datetime, person nvarchar(32))";
                    //string manufacture = @"CREATE TABLE MANUFACTURE (manufacture_code nvarchar(32) NOT NULL,name nvarchar(64),address nvarchar(64),license nvarchar(32))";
                    string classify = @"CREATE TABLE PRODUCT_CLASSIFY (code nvarchar(32) NOT NULL,name nvarchar(64))";
                    string product = @"CREATE TABLE PRODUCT (product_code nvarchar(32) NOT NULL,product_name nvarchar(64),classify nvarchar(64),format nvarchar(64),level nvarchar(64),location nvarchar(64))";
                    string account = @"CREATE TABLE ACCOUNT (name nvarchar(32) NOT NULL,password nvarchar(32))";
                    string salePoint = @"CREATE TABLE SALEPOINT (code nvarchar(50) NOT NULL,name nvarchar(50))";

                    DBAccess dbAccess = new SqlCeDBAccess();
                    dbAccess.excute(outLibrary);
                    dbAccess.excute(backLibrary);
                    dbAccess.excute(inLibrary);
                    //dbAccess.excute(manufacture);
                    dbAccess.excute(classify);
                    dbAccess.excute(product);
                    dbAccess.excute(account);
                    dbAccess.excute(salePoint);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return false;
            }
            return true;
        }
开发者ID:lishengtao,项目名称:Anli_Project,代码行数:42,代码来源:DBManager.cs

示例14: createDatabase

 public static void createDatabase(string filename, string path)
 {
     SqlCeEngine Engine = new SqlCeEngine(String.Format(@"DataSource={0}\{1}.sdf", path, filename));
     Engine.CreateDatabase();
     Engine.Dispose();
 }
开发者ID:luis-alberto-pena-nunez,项目名称:C-Sharp-Practice-004,代码行数:6,代码来源:DatabaseManager.cs

示例15: initDb

        private int initDb()
        {
            //sjekker om databasen allerede eksisterer
            if (File.Exists(fileName))
            {
                Logger.Info("Fant eksisterende database", thismodule);

                return (int)dbStatus.EXISTING;
            }
            else
            {
                Logger.Info("Oppretter ny database...", thismodule);
                //Dersom den ikke eksisterer opprettes databasen.
                SqlCeEngine en = new SqlCeEngine(ConnectionString);
                try
                {
                    en.CreateDatabase();
                }
                catch (Exception) { }
                finally
                {
                    en.Dispose();
                }

                //lager tabeller i databasen vi nettop opprettet.
                int cT = createTables();
                if (cT != (int)dbStatus.SUCCESS) //bruker != success slik at dbstatus kan kodes med flere forskjellige error koder senere.
                {
                    //TODO: gi melding til bruker om at noe gikk galt - se log.
                }
                Logger.Info("...Success", thismodule);
                return (int)dbStatus.NEW;
            }
        }
开发者ID:RepublicOfProgrammers,项目名称:polakken,代码行数:34,代码来源:DbHandler.cs


注:本文中的SqlCeEngine.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。