共用方式為


Database 建構函式

Initializes a new instance of the Database class.

命名空間:  Microsoft.SqlServer.Management.Smo
組件:  Microsoft.SqlServer.Smo (在 Microsoft.SqlServer.Smo.dll 中)

語法

'宣告
Public Sub New
'用途
Dim instance As New Database()
public Database()
public:
Database()
new : unit -> Database
public function Database()

備註

預設建構函式會初始化任何欄位至其預設值。

You will have to specify which server is the parent of the database before you can create a database.

範例

VB

Dim srv As Server
srv = New Server()

'Create a new database by using the default constructor.
Dim db As Database
db = New Database
db.Name = "New_Database"
db.Parent = srv
db.Create()

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$db = New-Object Microsoft.SqlServer.Management.Smo.Database
$db.Name = "New_Database"
$db.Parent = $srv
$db.Create()

請參閱

參考

Database 類別

Database 多載

Microsoft.SqlServer.Management.Smo 命名空間

其他資源

使用資料庫物件

建立、改變和移除資料庫

CREATE DATABASE (Transact-SQL)