469,625 Members | 1,123 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

How to execute DROP/CREATE TABLE from c#?

using System;
using System.Data;
using System.Data.SqlClient;

class App
{
static void Main(string[] args)
{
string SQL = @"Create table Foo
(
Bar int
)";
SqlConnection conn = new SqlConnection("server=.;integrated security=SSPI; database=pubs");

conn.Open();

SqlCommand cmd = new SqlCommand(SQL, conn);

cmd.ExecuteNonQuery();
}
}
Obviously you need the permissions in the database to be able to perform the operations

Regards

Richard Blewett - DevelopMentor

http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<A3**********************************@microsoft.co m>

How can I execute a DROP/CREATE TABLE statement from code using c#?

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004

[microsoft.public.dotnet.languages.csharp]
Nov 16 '05 #1
0 7097

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by James Knowlton | last post: by
3 posts views Thread by David Link | last post: by
5 posts views Thread by Andrew | last post: by
reply views Thread by Andres Romero | last post: by
2 posts views Thread by Brian Tkatch | last post: by
6 posts views Thread by Oliver | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.