需要在程序中实现类似于 sql server 企业管理器的功能,做成数据库。而且程序是要运行在客户端,给服务器添加新的数据库。。现在遇到了一个问题,就是如何指定做成数据库文件(data ,log)在服务器端的路径。
而且要判断指定的路径,在服务器上是否存在。 并判断服务器端空间是否足够!(就类似于企业管理器中做成数据库时候,指定路径以及判断空间的功能。)急用!
而且要判断指定的路径,在服务器上是否存在。 并判断服务器端空间是否足够!(就类似于企业管理器中做成数据库时候,指定路径以及判断空间的功能。)急用!
Private Function CreateDatabase(ByVal sDatabase As String, ByVal sDBPath As String, ByVal sLogPath As String) As Boolean
Dim sSQL As String
sSQL = "CREATE DATABASE " & sDatabase & " " & vbCrLf & _
"ON " & vbCrLf & _
"( NAME = " & Wrap(sDatabase & "_dat") & "," & vbCrLf & _
"FILENAME = " & Wrap(sDBPath) & "," & vbCrLf & _
"SIZE = 10, " & vbCrLf & _
"MAXSIZE = 500, " & vbCrLf & _
"FILEGROWTH = 5 ) " & vbCrLf & _
"LOG ON " & vbCrLf & _
"( NAME = " & Wrap(sDatabase & "_log") & ", " & vbCrLf & _
"FILENAME = " & Wrap(sLogPath) & "," & vbCrLf & _
"SIZE = 5MB," & vbCrLf & _
"MAXSIZE = 25MB," & vbCrLf & _
"FILEGROWTH = 5MB ) "
CreateDatabase = ExecuteSQL(sSQL)
End FunctionDir判断是否有文件存在Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias "GetDiskFreeSpaceExA" (ByVal lpRootPathName As String, lpFreeBytesAvailableToCaller As Currency, lpTotalNumberOfBytes As Currency, lpTotalNumberOfFreeBytes As Currency) As Long
Private Declare Function GetDiskFreeSpace Lib "kernel32" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTtoalNumberOfClusters As Long) As Long
判断剩余空间
Set the Name property of the Database object.
Create a DBFile object.
Set the Name property of the DBFile object.
Set the PhysicalName property of the DBFile object.
Set DBFile object properties optional for new database files, such as Size.
Add the DBFile object to the new Database object FileGroup object named PRIMARY.
Add the Database object to the Databases collection of a connected SQLServer object
Set the Name property.
Set the PhysicalName property.
Set the LogFile Size property.
Add the LogFile object to the LogFiles collection of the TransactionLog object of the new Database object.
The SpaceAvailable property returns the amount of disk resource allocated and unused in operating system files implementing Microsoft® SQL Server™ 2000 database and database transaction log storage.
就跟企业管理器那个窗口一样啊。 DMO 中有没有这样的一个对象阿,应该有的吧!
你如找到了,别忘了告诉我一声。
2,备份更改过的数据是只对上次备份后发生过修改的数据做备份,恢复时必须先从对上次整体备份的恢复开始,然后逐个对差异备份做恢复,直至所要恢复的恢复点(时间点)
SQLDMORECOVERY_Full 2 Use the Full Recovery model.
SQLDMORECOVERY_Simple 0 Use the simpleRecovery model.
SQLDMORECOVERY_Unknown 3 Recovery model is unknown.
怎么在做成数据库的时候,设置为其中一个?用SQLDMO实现!!
你用的不是SQLDMO.Restore Object?
To perform a complete database restore Create a Restore object.
Set a media property, naming the source device(s).
Set the Database property to indicate the target database.
If necessary, set the ReplaceDatabase property to force database creation.
Call the SQLRestore method.
To restore a single unit of a database log Create a Restore object.
Set the Action property to SQLDMORestore_Log.
Set a media property, naming the source device(s).
Set the Database property to indicate the target database.
Call the SQLRestore method.
To restore a database log chain Create a Restore object.
Set the Action property to SQLDMORestore_Log.
Set the Database property to indicate the target database.
Set the LastRestore property to FALSE.
Set a media property, naming the source device(s).
Call the SQLRestore method.
Repeat Steps 5 and 6 for all but the last unit in the database log chain.
Set the LastRestore property to TRUE.
Call the SQLRestore method to restore the last unit.
To verify the integrity of backup media Create a Restore object.
Set a media property, naming the source device(s).
Call the SQLVerify method.
Note The Restore object is compatible with instances of SQL Server 2000 and SQL Server version 7.0. However, the Restore2 object extends the functionality of the Restore object for use with features that are new in SQL Server 2000.
objDatabase.DBOPTION.SelectIntoBulkCopy= True……………………但是这句就不行
objDatabase.DBOPTION.RecoveryMode = 1
因为DBOPTION里没有这个属性,
然后Database里不能用DBOPTION2 这个东西
现在用SQL语句来更改它了ALTER DATABASE DBName RECOVERY SET SIMPLE/FULL/BULK_LOGGED呵呵,就是抄了系统存储过程sp_dboption里最后的那句话!