dbdroptableoperation.cs
来自「一个通用的数据库访问层」· CS 代码 · 共 39 行
CS
39 行
using System;
using System.Data;
using System.Data.OleDb;
namespace YariSoft.DBUtil
{
public class DBDropTableOperation : DBSchemaOperation
{
#region Local variables
private string tableName = "";
#endregion
#region Constructor/Destructor
public DBDropTableOperation( OleDbConnection Connection, string TableName )
{
this.connection = Connection;
this.tableName = TableName;
}
#endregion
#region Public functions
public override bool PrepareSQL()
{
string tempSQL = "";
DataTable constraints = this.connection.GetOleDbSchemaTable( OleDbSchemaGuid.Foreign_Keys, new object [] {null, null, this.tableName});
foreach ( DataRow row in constraints.Rows ){
tempSQL += "ALTER TABLE [" + row["FK_TABLE_NAME"].ToString() + "] DROP CONSTRAINT " + row["FK_NAME"].ToString()+ "\r\n";
}
constraints.Dispose();
tempSQL += "DROP TABLE [" + this.tableName + "]";
this.strSQL = tempSQL;
return true;
}
#endregion
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?