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


C# Catalog.Create方法代码示例

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


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

示例1: Button_Click

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //创建数据库文件
            ADOX.Catalog catalog = new Catalog();
            catalog.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\test.mdb;Jet OLEDB:Engine Type=5");
            Debug.WriteLine("DataBase created");

            //建表
            ADODB.Connection cn = new ADODB.Connection();
            cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\test.mdb", null, null, -1);
            catalog.ActiveConnection = cn;

            ADOX.Table table = new ADOX.Table();
            table.Name = "FirstTable";

            ADOX.Column column = new ADOX.Column();
            column.ParentCatalog = catalog;
            column.Name = "RecordId";
            column.Type = DataTypeEnum.adInteger;
            column.DefinedSize = 9;
            column.Properties["AutoIncrement"].Value = true;
            table.Columns.Append(column, DataTypeEnum.adInteger, 9);
            table.Keys.Append("FirstTablePrimaryKey", KeyTypeEnum.adKeyPrimary, column, null, null);
            table.Columns.Append("CustomerName", DataTypeEnum.adVarWChar, 50);
            table.Columns.Append("Age", DataTypeEnum.adInteger, 9);
            table.Columns.Append("Birthday", DataTypeEnum.adDate, 0);
            catalog.Tables.Append(table);

            cn.Close();
        }
开发者ID:Iamnvincible,项目名称:csharppractice,代码行数:30,代码来源:MainWindow.xaml.cs

示例2: ClsDataBase

        public ClsDataBase()
        {
            //如果文件不存在就创建
            if (!File.Exists(_strDataSource))
            {
                ADOX.Catalog catalog = new Catalog();
                catalog.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +_strDataSource + ";Jet OLEDB:Engine Type=5");
            }

            //如果表不存在就创建。一个是main 表,另一个是printedRecords 表。我是用如下比较暴力的方式判断的,入托表存在,就会异常退出。
            commandExecuteNonQuery("create table main ( 表名 integer  identity(1,1) primary key , 导入时间 Date , 单号 text(50),档口 text(50) , 文件名 text(50)  );");
            //commandExecuteNonQuery("create table printedRecords ( 打印时间 Date , 表名 text(50) , 数据 memo , 打印数量 long);");//这个不需要了
        }
开发者ID:kerwinxu,项目名称:barcodeManager,代码行数:13,代码来源:ClsDataBase.cs

示例3: createAccessDB

 //创建数据库文件
 public string createAccessDB(string fileName)
 {
     //创建在当前应用目录下
     string currentDir = System.Environment.CurrentDirectory;
     string dbName = currentDir + "\\"+ fileName;
     Console.WriteLine(dbName);
     if (File.Exists(dbName))
     {
         return "应用目录下已经存在目标数据库文件。";
     }
     ADOX.Catalog catalog = new Catalog();
     string createString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dbName + ";Jet OLEDB:Engine Type=5";
     catalog.Create(createString);
     return "在当前文件目录下已创建Access DB。";
 }
开发者ID:cqpaul,项目名称:Tools,代码行数:16,代码来源:AccessDBHelper.cs

示例4: AccessDBHelper

        protected string dbPath = System.Environment.CurrentDirectory+ "\\NPL_DB.accdb"; //默认的路径

        #endregion Fields

        #region Constructors

        public AccessDBHelper()
        {
            //判断DB 是否存在
            if (File.Exists(dbPath))
            {
                connectionString = setConnectionString(dbPath);
            }
            else
            {
                string dbName = System.Environment.CurrentDirectory + "\\NPL_DB.accdb";
                ADOX.Catalog catalog = new Catalog();
                string createString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dbName + ";Jet OLEDB:Engine Type=5";
                catalog.Create(createString);
            }
        }
开发者ID:cqpaul,项目名称:Tools,代码行数:21,代码来源:AccessDBHelper.cs

示例5: Coupons_InitDataBase

        /// <summary>
        /// 建立 优惠劵 数据库
        /// </summary>
        public static void Coupons_InitDataBase()
        {
            // string sqlstr = "INSERT INTO WX_Coupons(CUserName, CUserPhone, CUserqq, WXOpenID)  VALUES   (N'" + CUserName + "',N'" + CUserPhone + "',N'" + CUserqq + "',N'" + Session["WXOpenID"] + "')";

            string PathDataBase = System.IO.Path.Combine(SYSTEMDIR, "USER_DIR\\SYSUSER\\Coupons\\db.dll");//"USER_DIR\\SYSUSER\\SYSSET\\" +
            if (System.IO.File.Exists(PathDataBase) == true )
            {
               return;
            }

            try
            {

                ADOX.Catalog catalog = new Catalog();
                catalog.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + PathDataBase + ";Jet OLEDB:Engine Type=5");

                ADODB.Connection cn = new ADODB.Connection();

                cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + PathDataBase, null, null, -1);
                catalog.ActiveConnection = cn;

                if (true)
                {
                    ADOX.Table table = new ADOX.Table();
                    table.Name = "WX_Coupons";
                    ADOX.Column column = new ADOX.Column();
                    column.ParentCatalog = catalog;
                    column.Name = "WXOpenID";
                    column.Type = DataTypeEnum.adInteger;
                    column.DefinedSize = 7;
                    column.Properties["AutoIncrement"].Value = true;
                    table.Columns.Append(column, DataTypeEnum.adInteger, 7);
                    table.Keys.Append("FirstTablePrimaryKey", KeyTypeEnum.adKeyPrimary, column, null, null);
              // string sqlstr = "INSERT INTO WX_Coupons(CUserName, CUserPhone, CUserqq, WXOpenID)  VALUES   (N'" + CUserName + "',N'" + CUserPhone + "',N'" + CUserqq + "',N'" + Session["WXOpenID"] + "')";
                    table.Columns.Append("CUserName", DataTypeEnum.adVarWChar, 200);
                    table.Columns.Append("CUserPhone", DataTypeEnum.adVarWChar, 200);
                    table.Columns.Append("CUserqq", DataTypeEnum.adVarWChar, 200);
                    catalog.Tables.Append(table);
                }
                cn.Close();
            }
            catch
            {

            }
        }
开发者ID:italiazhuang,项目名称:wx_ptest,代码行数:49,代码来源:ClassDirectoryMag.cs

示例6: CreateDB

        public static bool CreateDB(string pstrDB)
        {
            try
            {
                Catalog cat = new Catalog();
                string strCreateDB = "";

                strCreateDB += "Provider=Microsoft.Jet.OLEDB.4.0;";
                strCreateDB += "Data Source=" + pstrDB + ";";
                strCreateDB += "Jet OLEDB:Engine Type=5";
                cat.Create(strCreateDB);

                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
开发者ID:TheNotary,项目名称:database_functions,代码行数:19,代码来源:Class1.cs

示例7: CreateNewDatabase

        /// <summary>
        /// Creates new database file
        /// </summary>
        /// <returns>True if success</returns>
        public bool CreateNewDatabase()
        {
            try
            {
                _cat = new Catalog();
                string strCreateDB = GenerateConnectionString();
                _cat.Create(strCreateDB);
                _cat.let_ActiveConnection(strCreateDB);

                CreateTableXmlTable();
                CreateTableTags();
                CreateTableXmlTagsRelation();
                CreateTableUser();

                return true;
            }
            catch (Exception)
            {
                //TODO: Error logging
                return false;
            }
        }
开发者ID:szpaqq,项目名称:SourceCode,代码行数:26,代码来源:DataBase.cs

示例8: CreateAccessDb

        /// <summary>
        /// 创建access数据库
        /// </summary>
        /// <param name="filePath">数据库文件的全路径,如 D:\\NewDb.mdb</param>
        public static bool CreateAccessDb(string accessFile)
        {
            string end = ".accdb";

            ADOX.Catalog catalog = new Catalog();
            if (!File.Exists(accessFile))
            {
                try
                {
                    catalog.Create(url + accessFile + end );
                }
                catch (System.Exception ex)
                {
                    return false;
                }
            }

            // create the db's table totalTable , purviewTable
            CreateDeptTotalTab(accessFile);
            CreatePurviewTab(accessFile);
               // end the create two table

            return true;
        }
开发者ID:myhubxxx,项目名称:maolili_C,代码行数:28,代码来源:AccessOp.cs

示例9: CreatDb

        /// <summary>
        /// 创建新的信息数据库
        /// </summary>
        private void CreatDb()
        {
            string con = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=dac.accdb";

            ADOX.Catalog catalog = new Catalog();
            catalog.Create(con);//创建新的数据库

            catalog.ActiveConnection();
            ADODB.Connection connection = new ADODB.Connection();
            connection.Open(con, null, null, -1);

            //新建主体信息数据表
            ADOX.Table table = new Table();
            table.Name = "主体信息表";

            ADOX.Column subjectName = new Column();//主体名称
            subjectName.Name = "主体名称";
            ADOX.Column pwd = new Column();//主体登录密码
            pwd.Name = "密码";
            ADOX.Column SubjectRegisterTime = new Column();//主体登录密码
            SubjectRegisterTime.Name = "注册时间";

            table.Columns.Append(subjectName);//将列添加到表中
            table.Columns.Append(pwd);
            table.Columns.Append(SubjectRegisterTime);
            catalog.Tables.Append(table);

            //新建角色信息数据表
             table = new Table();
            table.Name = "角色信息表";

            ADOX.Column RoleName = new Column();//角色名称
            RoleName.Name = "角色名称";

            ADOX.Column RoleRegisterTime= new Column();//角色注册时间
            RoleRegisterTime.Name = "创建时间";

            table.Columns.Append(RoleName);//将列添加到表中
            table.Columns.Append(RoleRegisterTime);
            catalog.Tables.Append(table);
            //新建角互斥色信息数据表
            table = new Table();
            table.Name = "互斥角色信息表";

            ADOX.Column ExclusionRoleName = new Column();//角色名称
            ExclusionRoleName.Name = "角色1名称";
            ADOX.Column ExclusionRoleName1 = new Column();//角色名称
            ExclusionRoleName1.Name = "角色2名称";

            table.Columns.Append(ExclusionRoleName);//将列添加到表中
            table.Columns.Append(ExclusionRoleName1);
            catalog.Tables.Append(table);

            //新建角色关系信息数据表
            table = new Table();
            table.Name = "角色关系信息表";
            ADOX.Column FatherRoleName = new Column();//角色名称
            FatherRoleName.Name = "父角色名称";
            ADOX.Column ChildRoleName = new Column();//角色名称
            ChildRoleName.Name = "子角色名称";
            table.Columns.Append(FatherRoleName);//将列添加到表中
            table.Columns.Append(ChildRoleName);
            catalog.Tables.Append(table);

            //新建权限信息表
            table = new Table();
            table.Name = "权限信息表";
            ADOX.Column PermissionName = new Column();//权限名称
            PermissionName.Name = "权限名称";
            ADOX.Column PermissionRegisterTime = new Column();//权限创建注册时间
            PermissionRegisterTime.Name = "创建时间";

            table.Columns.Append(PermissionName);//将列添加到表中
            table.Columns.Append(PermissionRegisterTime);
            catalog.Tables.Append(table);

            //新建用户角色指派信息表
            table = new Table();
            table.Name = "用户-角色指派信息表";
            ADOX.Column UserName = new Column();//用户名称
            UserName.Name = "用户名称";
              RoleName = new Column();//角色名称
            RoleName.Name = "角色名称";

            table.Columns.Append(UserName);//将列添加到表中
            table.Columns.Append(RoleName);
            catalog.Tables.Append(table);

            //新建角色到权限的指派信息表

            table = new Table();
            table.Name = "角色-权限指派信息表";
            RoleName = new Column();//角色名称
            RoleName.Name = "角色名称";
            PermissionName = new Column();//权限名称
            PermissionName.Name = "权限名称";

//.........这里部分代码省略.........
开发者ID:xxxhycl2010,项目名称:RBAC-1,代码行数:101,代码来源:Login.cs

示例10: CreateDataTable

        //保存数据
        private void CreateDataTable()
        {
            startTime = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString() + "-" + DateTime.Now.Hour.ToString() + "-" + DateTime.Now.Minute.ToString() + "-" + DateTime.Now.Second.ToString();

            ADOX.Catalog catalog = new Catalog();
            string tableName = startTime;

            string myDataPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + "D:\\Data\\" + tableName + ".mdb";
            myConnectionString = myDataPath;
            catalog.Create(myDataPath + ";Jet OLEDB:Engine Type=5");

            ADODB.Connection connection = new ADODB.Connection();
            connection.Open(myDataPath, null, null, -1);
            catalog.ActiveConnection = connection;

            ADOX.Table table = new ADOX.Table();
            table.Name = "Data";
            ADOX.Column column = new ADOX.Column();
            column.ParentCatalog = catalog;
            column.Name = "Num_My";
            column.Type = DataTypeEnum.adInteger;
            column.DefinedSize = 9;
            column.Properties["AutoIncrement"].Value = true;
            table.Columns.Append(column, DataTypeEnum.adInteger, 12);
            table.Keys.Append("FirstTablePrimaryKey", KeyTypeEnum.adKeyPrimary, column, null, null);

            table.Columns.Append("Date", DataTypeEnum.adDate, 20);
            table.Columns.Append("Position", DataTypeEnum.adSingle, 9);

            catalog.Tables.Append(table);
        }
开发者ID:huiminer,项目名称:Common,代码行数:32,代码来源:spq_dat.cs

示例11: Turntable_InitDataBase

        /// <summary>
        /// 建立 大转盘 数据库
        /// </summary>
        public static void Turntable_InitDataBase()
        {
            string PathDataBase = System.IO.Path.Combine(SYSTEMDIR, "USER_DIR\\SYSUSER\\Turntable\\db.dll");//"USER_DIR\\SYSUSER\\SYSSET\\" +
            if (System.IO.File.Exists(PathDataBase) == true)
            {
                return;
            }

            try
            {

                ADOX.Catalog catalog = new Catalog();
                catalog.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + PathDataBase + ";Jet OLEDB:Engine Type=5");

                ADODB.Connection cn = new ADODB.Connection();

                cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + PathDataBase, null, null, -1);
                catalog.ActiveConnection = cn;

                //     string Data1 = "CREATE TABLE WX_GGK( \r\n";
                //     Data1 += "ID int IDENTITY(1,1) NOT NULL,\r\n";
                //     Data1 += "Name nvarchar(200) NULL,\r\n";
                //     Data1 += "Cs int NULL\r\n";
                //     Data1 += ") ON PRIMARY\r\n";

                //            Data1 += "CREATE TABLE WX_GGK_JP(\r\n";
                //Data1 += "ID int IDENTITY(1,1) NOT NULL,\r\n";
                //Data1 += "Name nvarchar(200) NULL,\r\n";
                //Data1 += "Jp nvarchar(50) NULL,\r\n";
                //Data1 += "SJH nvarchar(50) NULL\r\n";
                //Data1 += ") ON PRIMARY\r\n";

                //     object dummy = Type.Missing;
                //     cn.Execute(Data1, out dummy, 0);
                  if (true)
                    {
                        ADOX.Table table = new ADOX.Table();
                        table.Name = "wx_dzp";
                        ADOX.Column column = new ADOX.Column();
                        column.ParentCatalog = catalog;
                        column.Name = "ID";
                        column.Type = DataTypeEnum.adInteger;
                        column.DefinedSize = 7;
                        column.Properties["AutoIncrement"].Value = true;
                        table.Columns.Append(column, DataTypeEnum.adInteger, 7);
                        table.Keys.Append("FirstTablePrimaryKey", KeyTypeEnum.adKeyPrimary, column, null, null);

                        table.Columns.Append("Name", DataTypeEnum.adVarWChar, 200);
                        table.Columns.Append("Cs", DataTypeEnum.adInteger, 7);

                        catalog.Tables.Append(table);
                    }

                if (true)
                {
                    ADOX.Table table = new ADOX.Table();
                    table.Name = "wx_dzp_jp";
                    ADOX.Column column = new ADOX.Column();
                    column.ParentCatalog = catalog;
                    column.Name = "ID";
                    column.Type = DataTypeEnum.adInteger;
                    column.DefinedSize = 7;
                    column.Properties["AutoIncrement"].Value = true;
                    table.Columns.Append(column, DataTypeEnum.adInteger, 7);
                    table.Keys.Append("FirstTablePrimaryKey", KeyTypeEnum.adKeyPrimary, column, null, null);

                    table.Columns.Append("Name", DataTypeEnum.adVarWChar, 200);
                    table.Columns.Append("Jp", DataTypeEnum.adVarWChar, 200);
                    table.Columns.Append("SJH", DataTypeEnum.adVarWChar, 200);

                    catalog.Tables.Append(table);
                }

                cn.Close();

            }
            catch
            {

            }
        }
开发者ID:italiazhuang,项目名称:wx_ptest,代码行数:84,代码来源:ClassDirectoryMag.cs

示例12: CreateFile

        //Создание нового файла
        public bool CreateFile(string filename, string password)
        {
            if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "DataBase\\"))
            {
                Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "DataBase\\");
            }

            ADOX.Catalog cat = new Catalog();
            DBpath = AppDomain.CurrentDomain.BaseDirectory + "DataBase\\" + filename + ".mdb";
            if (File.Exists(DBpath))
            {
                MessageBox.Show("Файл с таким именем уже существует!");
                return false;
            }
            else
            {
                DBsettings = "provider=Microsoft.Jet.OleDb.4.0;Data Source=" + DBpath + ";Jet OLEDB:Database Password=" + password + ";";
                cat.Create(DBsettings);
                cat = null;
                CreateTable("CREATE TABLE People(ID Identity(1,1), " + "Фамилия String, " + "Имя String, " + "Отчество String, " + "Дата_Рождения Date, " + "Телефон String, " + "Адресс String, " + "Email String, " + "Кем_Является String, " + "Доп_Информация String, " + "Взял_В_Займы Double, " + "Дал_В_Займы Double, " + "Долг Double, " + "Фото IMAGE, " + "Primary Key (ID));");
                return true;
            }
        }
开发者ID:UlqCifer,项目名称:Study,代码行数:24,代码来源:WorkWithDB.cs

示例13: Create

        // ======================================================
        // Private Member Functions
        // ======================================================
        private static void Create()
        {
            // create the database file
            Catalog cat = new Catalog();
            cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" +
                "Data Source=PowerSDR.mdb;" +
                "Jet OLEDB:Engine Type=5");

            // Create the tables
            AddFormTable(ref cat, "State");
            AddFormTable(ref cat, "Options");
            AddFormTable(ref cat, "CWX");
            AddBandTextTable(ref cat);
            AddBandStackTable(ref cat);
            AddMemoryTable(ref cat);
            AddGroupListTable(ref cat);
            AddFormTable(ref cat, "UCB");
            AddFormTable(ref cat, "XVTR");
            AddTxProfileTable(ref cat);
            AddIQTable(ref cat);
            AddFormTable(ref cat, "EQForm");
            AddFormTable(ref cat, "ProdTest");
            AddFormTable(ref cat, "WaveOptions");
            AddFormTable(ref cat, "FWCMixer");
            AddFormTable(ref cat, "FLEX5000LLHWForm");
            AddFormTable(ref cat, "FLEX5000DebugForm");
            AddFormTable(ref cat, "FLEX5000ProdTestForm");
            AddFormTable(ref cat, "FLEX5000FinalTestForm");
            AddFormTable(ref cat, "FLEX5000RX2CalForm");
            AddFormTable(ref cat, "FWCAnt");
            AddFormTable(ref cat, "FWCATU");

            cat = null;
        }
开发者ID:ae6jl-mdd,项目名称:powersdr-iq,代码行数:37,代码来源:database.cs

示例14: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            if (INFOMODE) return;
            string pstrDB = txtDbPath.Text;

            try
            {
                Catalog cat = new Catalog();                    // WARNING!  To get this to work you need to include Microsoft ADO 2.x in references
                string strCreateDB = "";
                strCreateDB += "Provider=Microsoft.Jet.OLEDB.4.0;";
                strCreateDB += "Data Source=" + pstrDB + ";";
                strCreateDB += "Jet OLEDB:Engine Type=5";
                strCreateDB = MyConString;
                cat.Create(strCreateDB);

                // The junk below closes the connection.  You only need this if you rly want to delete the file after I guess...
                //  Microsoft ActiveX Data Objects 2.8 Library
                //ADODB.Connection connection = (ADODB.Connection)cat.ActiveConnection;   // we're not goona use this method of closing as a means to omit the ActiveX object library
                //connection.Close();

                //Marshal.ReleaseComObject(cat);         // we don't need this to close the connection anymore... just interesting
                cat = null;
                GC.Collect(); // This is the last resort - don't use if ReleaseComObject works.
            }
            catch (Exception)
            {
                MessageBox.Show("Already exists (probably)");
                SetDbsExistance();
                return;
            }

            SetDbsExistance();
        }
开发者ID:TheNotary,项目名称:__AccessDatabaseWEB,代码行数:33,代码来源:Form1.cs

示例15: createFile

 private void createFile()
 {
     Catalog catalog = new Catalog();
     catalog.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + base.FileName + ";Jet OLEDB:Engine Type=5");
     catalog = null;
 }
开发者ID:zformular,项目名称:ValueHelper,代码行数:6,代码来源:AccessHelp.cs


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