hello to all. I have a problem. I want to alter a table to add three columns whenever i click a button.But i want the name of the table taken from a drop down list, and the name of the three columns are also taken from either a drop down list or a textbox. Here's the code that i used as trial for the first column:
con.Open()
cmd = New SqlCommand("ALTER TABLE " + ddl_sub.Text + " ADD " + txt_desc.Text + " varchar(50) ", con)
cmd.CommandType = CommandType.Text
cmd.ExecuteNonQuery()
con.Close()
However, when i try it, it say "incorrect syntax near varchar" and when i add (') the error becomes "incorrect syntax near 'quiz'". If i change it back, the code works but if i click the button again, "incorrect syntax near varchar" appears again... Help please.. Is my code wrong? i'm new at this. By the way im making use of sql server