vb.net - Database Not Exist, but it is exist at there -


at project having 2databases , server using sql server 2012 management studio. , connect 1 of database , made new table in runtime. i'm having problem.

database not exist

but when check location. exist , same name..

here code : enter image description here

private sub vbcreate()         dim sqlcon2 new sqlconnection(vbcon)         mainmenu.lblstatus.text = "creating virtual book"         sqlstr = ("use [virtualbook] " & _                   "go() " & _                   "set ansi_nulls on" & _        " go() " & _         "set quoted_identifier on" & _         " go() " & _      "create table [dbo].[" & tbemail.text & "](" & _                       "[id] [ntext] null, " & _     "[remarks] [nchar](6) null " & _ ") on [primary] textimage_on [primary]")          try             sqlcon2.open()             cmd = new sqlcommand(sqlstr, sqlcon2)             cmd.commandtype = commandtype.text             cmd.executenonquery()             sqlcon2.close()             mainmenu.lblstatus.text = "command saved server"         catch ex exception             msgbox(ex.message)                     sqlcon2.close()         end try      end sub 

i follow on @ivanh , @steve, @gbn. remove go.. first got error too. remove use statments.

and remove cmd.commandtype statements too. it's run, have test insert , select database table , show well.. below code. if there bad logic of code. please give me advice, cause still beginner this. time all..

 dim sqlcon2 new sqlconnection(my.settings.sqlvb)         mainmenu.lblstatus.text = "creating virtual book"         sqlstr2 = "create table [dbo].[" & tbemail.text & "](" & _                       "[id] [ntext] null, " & _     "[remarks] [nchar](6) null " & _ ") on [primary] textimage_on [primary]"         try             sqlcon2.open()             cmd = new sqlcommand(sqlstr2, sqlcon2)              cmd.executenonquery()             sqlcon2.close()             mainmenu.lblstatus.text = "command saved server"         catch ex exception             msgbox(ex.message)         end try 

and change connection directly my.settings.sqlvb. can see string @ picture above(my question)


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -