DataContext.DatabaseExists 方法

定义

确定是否可以打开关联数据库。Determines whether the associated database can be opened.

public:
 bool DatabaseExists();
public bool DatabaseExists ();
member this.DatabaseExists : unit -> bool
Public Function DatabaseExists () As Boolean

返回

Boolean

如果可以打开指定的数据库,则为 true;否则为 falsetrue if the specified database can be opened; otherwise, false.

示例

下面的示例使用此方法来确定数据库是否已存在。The following example uses this method to determine whether a database already exists.

if (!db.DatabaseExists())
    db.CreateDatabase();
// …
db.DeleteDatabase();
If Not db.DatabaseExists Then
    db.CreateDatabase()
End If
' ...
db.DeleteDatabase()

注解

此方法使用属性中的连接 Connection 来尝试打开关联的数据库。This method uses the connection in the Connection property to attempt to open the associated database.

适用于