private void button1_Click(object sender, EventArgs e) { try { SqlConnection con = new SqlConnection(@"Data Source=ASUS\SQLEXPRESS;Initial Catalog=E1;Integrated Security=True;"); con.Open(); // string str = "CREATE TABLE'"+textBox1.Text+"(userid number(10),password varchar2(20),email varchar2(20));'"; string str = "CREATE TABLE " + textBox1.Text + " (dataid varchar(10), data varchar());"; SqlCommand cmd = new SqlCommand(str, con); cmd.ExecuteNonQuery(); string str1 = "insert into users(userid,password,email) values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox4.Text + "')"; SqlCommand cmd1 = new SqlCommand(str1, con); cmd1.ExecuteNonQuery(); MessageBox.Show("Table created"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
"CREATE TABLE " + textBox1.Text + " (dataid varchar(10), data varchar(10));";
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)