vb.net - Creating SQL table from variable with spaces in the name -


i trying create sql table using vb.net, using variable.

the issue table name derivation of filename , can contain space.

below example of code:

    dim openfiledialog1 new openfiledialog     dim strfilename string     dim filenameonly string      openfiledialog1.initialdirectory = "c:\***\***\***"     openfiledialog1.filter = "csv files (*.csv)|*.csv"     openfiledialog1.filterindex = 2     openfiledialog1.restoredirectory = true      if openfiledialog1.showdialog = windows.forms.dialogresult.ok      end if     strfilename = openfiledialog1.safefilename     if strfilename <> ""          filenameonly = system.io.path.getfilenamewithoutextension(openfiledialog1.filename)         textbox1.text = filenameonly  using con = new sqlconnection("server=***\sqlexpress; database=***billing; integrated security=yes")             using cmda = new sqlcommand("create table '" + filenameonly + "' (calltype varchar(30),chargecode varchar(30),destination varchar(30),tariffused varchar(30),peak float,offpeak float,weekend float,setup float,minimumcharge float,chargecap int,initialunits int,initialcharge int,initialpeak int,initialoffpeak int,initialweekend int,billingunit int,minimumunits int,ratetype varchar(30));", con)                 con.open()                 cmda.executenonquery()                 con.close()             end using         end using 

...this error get

"additional information: incorrect syntax near 'ffa68878 cps rates'."

the safe filename "ffa68878 cps rates"

can correct syntax?

any appreciated :)

put table , column name (with spaces) within square brackets like

using cmda = new sqlcommand("create table [" + filenameonly + "] (calltype . . .ratetype varchar(30));", con) 

note . . .[" + filenameonly + "]. . . above.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -