Creating an application and can't figure out how I can create multiple tables in an sql database by clicking on a form? I have 2 connection. 1 connection for create database, 2 connection for create table in database
public partial class Form1 : Form
{
static string constring = ConfigurationManager.ConnectionStrings["Test.Properties.Settings.Setting"].ConnectionString;
SqlConnection connstringsql = new SqlConnection(constring);
//for create table in database
static string create =
ConfigurationManager.ConnectionStrings["Test.Properties.Settings.Setting1"].ConnectionString;
SqlConnection connscreate = new SqlConnection(create);
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//create table
connscreate.Open();
string sqlqueryone = "CREATE TABLE test";
SqlCommand sqlcomm = new SqlCommand(sqlqueryone, connscreate);
connscreate.Close();
}
When I click on the button in the base to create several tables.


SqlConnection; this brings nothing but headaches. Create them as needed and keep them inusingblocks with as small a scope as reasonable (ditto forSqlCommand). AnSqlConnectionrepresents a handle to a pooled connection; you do not need to optimize their creation. Also, obviously, yourCREATE TABLEstatement as given is invalid; a table must have at least one column.sqlcomm