c# - Create Table SQL query - select table name from string -



c# - Create Table SQL query - select table name from string -

i'm attempting programmatically create sql table. can create table query, no issue @ all. i'd table name have relevance info inserted it, it's beingness used quotations , invoices. info entered datagridview inserted (probably via bulkcopy, or similar).

using (sqlcecommand command = new sqlcecommand( "create table table1' (weight int, name nvarchar, breed nvarchar)", con))

works perfectly. i'd code work:

using (sqlceconnection con = new sqlceconnection(@"data source=|datadirectory|\lwadatabase.sdf")) { con.open(); seek { string tablename = "" + quotenametxt.text + "-" +firsttxt.text+ "-" + surenametxt.text; using (sqlcecommand command = new sqlcecommand( "create table '"+tablename.tostring()+"' (weight int, name nvarchar, breed nvarchar)", con)) { command.executenonquery(); } } grab (exception ex) { messagebox.show(ex.message); } }

any suggestions? error (as expected) unsure need do.

i'm using sqlce (and before says "bulkcopy isn't supported", know, i've got reference allows it)

the error :

there error parsing query. [ token line number = 1,token line offset = 16,token in error = 1-2-3 ]

// "1-2-3" beingness textbox values.

change dashes underscores or surround entire table name [square brackets]

c# sql database datatable create-table

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -