Сохранение таблицы в базе данных master
я создаю базу данных с именем "TestScript", но когда я создаю таблицу
сохранение таблицы в базе данных "мастер"
Я хочу сохранить в базе данных "TestScript"
Что я уже пробовал:
Imports System.Configuration Imports System.Data.SqlClient Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim SQLConnectionString As String = "Data Source=COMPUTECH-PC\SQLEXPRESS;Initial Catalog=Master;Integrated Security=true;User ID=sa;Password=", providerName = "System.Data.SqlClient" Using SqlCon As SqlConnection = New SqlConnection(SQLConnectionString) Dim str As String str = "CREATE DATABASE SQLSqript ON PRIMARY (NAME = SQLSqript_Data, FILENAME = 'C:\COMPUTECH\SQLSqript.mdf', " & _ " SIZE = 2MB, MAXSIZE = 10MB, FILEGROWTH = 10%) LOG ON(NAME = SQLSqript_Log, FILENAME = 'C:\COMPUTECH\SQLSqript.Log'," & _ " SIZE = 1MB,MAXSIZE = 5MB, FILEGROWTH = 10%) " Dim cmd As SqlCommand = New SqlCommand(str, SqlCon) Try cmd.Connection.Open() cmd.ExecuteNonQuery() cmd.Connection.Close() Catch MsgBox(" Already installed database", MsgBoxStyle.Critical) End Try Try Dim sql As String sql = "CREATE TABLE [dbo].[Script]([Name] [nvarchar](50) NULL,[Address] [nvarchar](50) NULL,[Phone] [nvarchar](50) NULL) ON [PRIMARY]" cmd = New SqlCommand(sql, SqlCon) cmd.Connection.Open() cmd.ExecuteNonQuery() cmd.Connection.Close() Catch MsgBox(" Already installed database", MsgBoxStyle.Critical) End Try End Using End Sub End Class