The AttachDBWithSingleFile method makes a database visible to a Microsoft® SQL Server™ installation.
object.AttachDBWithSingleFile( DBName , DataFile ) as String
Part | Description |
---|---|
object | Expression that evaluates to an object in the Applies To list |
DBName | String specifying an existing database by name |
DataFile | String specifying the database PRIMARY data file by operating system file name |
A string indicating success or failure.
The AttachDBWithSingleFile method is used when a change to the location of operating system files implementing the database must be made visible to the SQL Server installation.
The DataFile argument specifies a single operating system data file implementing storage for a SQL Server database. The SQL Server installation creates an operating system file for transaction log record maintenance as part of the AttachDBWithSingleFile method processing.
Important The AttachDBWithSingleFile method only succeeds when storage for a database is implemented within a single operating system file. A file or files implementing storage for database transaction log records are not made visible by the method. For more information about making multifile databases visible to a SQL Server installation, see AttachDB Method.
Making a database visible to a SQL Server installation by using the AttachDBWithSingleFile method requires appropriate privilege. The SQL Server login used for SQLServer object connection must be a member of the system-defined role sysadmin.
HRESULT AttachDBWithSingleFile(SQLDMO_LPCSTR DBName,
SQLDMO_LPCSTR DataFile,
SQLDMO_LPBSTR pResult);