Monday, July 27, 2009

How can I create table in SQL Server 2000 at runtime using C#??????

I want to create table in SQL Server 2000 as the page load using C# with proper attributes defined in the table while creating table.


Please suggest me if any one knows the answer.

How can I create table in SQL Server 2000 at runtime using C#??????
Look at the System.Data.SqlClient namespace.





SqlConnection connection = new SqlConnection(connectionString)


SqlCommand command = new SqlCommand()


command.CommandText = "CREATE TABLE foo (Col1 int not null)


command.Connection = connection;


command.ExecuteNonQuery()





There are also the ADO.NET calls if you don't like writing all the SQL queries. VS 2005 also comes with the Microsoft.SqlServer.Management.Smo assemblies and namespace which can do this too.

augustifolia

No comments:

Post a Comment