c# - Error in creating a table in mySQL -


i tried of suggestions still same error. have error in sql syntax; check manual corresponds mysql server version right syntax use near ''' (size int(5))' @ line 1

here code:

            try{             query = "create table @name (size int(5))";             mysqlcommand cmd = new mysqlcommand(query, con);               cmd.parameters.add("@name", mysqldbtype.varchar, 30).value = txtboxname.text;              con.open();             cmd.executenonquery();             con.close();             }             catch (exception)         {             throw;         }                 {             if (con.state == connectionstate.open)             {                 con.close();             }         } 

i think intended use backticks `` escape table name used single quotes instead.

  query = "create table `"+ txtboxname.text + "`(size int(5))"; 

Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -