在我有 2Databases 的项目中,我的服务器正在使用 SQL Server 2012 Management Studio。现在我想连接到其中一个数据库并在运行时创建一个新表。但我有一个问题。
但是当我检查到我的位置时。它存在并且具有相同的名称..
这是我的代码:
Private Sub VBcreate()
Dim sqlcon2 As 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 to Server"
Catch ex As Exception
MsgBox(ex.Message)
Finally
sqlcon2.Close()
End Try
End Sub