Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionstring lacon = DBconnexion.Properties.Settings.Default.Database1ConnectionString1; SqlConnection SqlCon = new SqlConnection(lacon); try { SqlCon.Open(); MessageBox.Show("connexion=ok"); } catch { MessageBox.Show("connexion has failed"); } SqlDataAdapter Sqldata = new SqlDataAdapter(); string cmd="CREATE TABLE securities2(Name char(30),Date datetime(10), Price money(10))"; Sqldata.SelectCommand=new SqlCommand(cmd);
string lacon = DBconnexion.Properties.Settings.Default.Database1ConnectionString1; SqlConnection SqlCon = new SqlConnection(lacon); bool connection_ok = false; try { SqlCon.Open(); MessageBox.Show("connexion=ok"); connection_ok = true; } catch { MessageBox.Show("connexion has failed"); } if (connection_ok == true) { try { SqlDataAdapter Sqldata = new SqlDataAdapter(); string cmd = "CREATE TABLE securities2(Name char(30),Date datetime(10), Price money(10))"; Sqldata.SelectCommand = new SqlCommand(cmd); MessageBox.Show("table created"); } catch { MessageBox.Show("query failed"); }
SqlDataAdapter Sqldata = new SqlDataAdapter(); string cmd = "CREATE TABLE securities2(Name char(30),Date datetime(10), Price money(10))"; Sqldata.SelectCommand = new SqlCommand(cmd);
string cmd = "CREATE TABLE securities2(Name char(30),Date datetime(10), Price money(10))"; SqlCommand sc = new SqlCommand(cmd); sc.executeNonQuery();