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
Post a Comment