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
}
}
|