publicvoid CreateTable(List<string> columnNames, string tableName)
{
string connectionString = Utility.ReadDataFromConfig("ConnectionTest");
using (var connection = new SqlConnection(connectionString))
{
var server = new Server(new ServerConnection(connection));
var db = server.Databases["GlassLookUp"];
var newTable = new Table(db, tableName);
var idColumn = new Column(newTable, "ID") { DataType = DataType.Int, Nullable = false };
newTable.Columns.Add(idColumn);
foreach (var titleColumn infrom temp in columnNames
where temp != string.Empty
selectnew Column(newTable, temp) { DataType = DataType.VarChar(500), Nullable = true })
{
newTable.Columns.Add(titleColumn);
}
newTable.Create();
}
}
</div>
I wanted the above method to be changed, so that Enterprise library is use. I have already used Enterprise library to execute stored procedures,but i dont know how to use Enterprise library to Create a Table.
uthappa
Member
51 Points
21 Posts
Create Table using Enterprise Library
Mar 17, 2011 11:42 AM|LINK
Hi,
I have a method through which i am creating a Table in DB as shown below,
<div style="font-weight: inherit; font-style: inherit; font-family: inherit; outline-width: 0px; outline-style: initial; outline-color: initial; color: black; background-color: white; padding: 0px; margin: 0px; border: 0px initial initial;"> </div>I wanted the above method to be changed, so that Enterprise library is use. I have already used Enterprise library to execute stored procedures,but i dont know how to use Enterprise library to Create a Table.
Thanks
enterprise