本文整理匯總了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();
}
示例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);");//這個不需要了
}
示例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。";
}
示例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);
}
}
示例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
{
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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 = "權限名稱";
//.........這裏部分代碼省略.........
示例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);
}
示例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
{
}
}
示例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;
}
}
示例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;
}
示例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();
}
示例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;
}