1

I tried so many things but I couldn't find a solution..

private void button1_Click_1(object sender, EventArgs e)
    {

        string NewTable = TxtPanoNo.Text;


        try
        {
            using (SqlCommand command = new SqlCommand("CREATE TABLE" + NewTable + ""+ "(id tinyint,KullanilanAdet smallint,Tip nchar(20),Kod varchar(50),Ad varchar(50),Aciklama varchar(500),Favori bit)", bgl.baglanti()))
            command.ExecuteNonQuery();

        MessageBox.Show("Succeed");
        }

        catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }



    }

and the error is:

incorrect syntax near '('.

1
  • Apart from the simple syntax error which you could've spotted by inspecting the string, why do you want to create tables on demand? Shouldn't PanoNo simply be a column in the same table? Commented Nov 30, 2018 at 10:25

1 Answer 1

3

There is no space between CREATE TABLE and the table-name. Instead use:

"CREATE TABLE " + NewTable + "(id tinyint, ... and so on  
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.