欲在安装该系统时自动在系统找寻找sqlserver,然后建立一数据库,然后建立表和视图和触发器,解决后再送50.
解决方案 »
- SQL语句
- winsock发送邮件问题!!!在线急等
- [还是不懂~~~]如何读取某一个word文档内容,并依次保存到一个数组中去(以回车为分隔)?
- 高分求解,对高手可能很简单..。
- 在windows2000中是否存在自定义纸张?
- 我要用sql语句中的sum汇总字段为“文本”类型的数据,有方法吗?
- 谁有dll程序及相关程序的原代码?贴出原代码优先给分
- 怎样将一个程序做为系统进程来运行,就让它每次开机都自动远行,用代码来实现???
- 部件'RICHTX32.ocx'或其部件之一不能正确注册:一个文件丢失或无效!!!!!!我该怎么办?
- 用文本文件对数据进行存储,当数据量大的时候。速度是否受到限制?好像是。因为没有索引。可是,这样可以省很多钱(正版软件)。要使用access要快一些!!现在正在犹豫中。欢迎大家来指教!!!
- 谁知道那里有编写ie风格的按钮控件的源代码,刘清涛的写的那个源代码不全,谁有全的
- 这个问题好怪!!!!!
MSN:[email protected],请先说明是VB。
e妹:[email protected]
Public Function Create(ByVal lConnID As Long, ByVal sSurveyName As String, _
ByVal sCustomerName As String) Dim sCustomerID As String
Dim sDBName As String
Dim sDFName As String
Dim sLFName As String
Dim sDriveAndPath As String
Dim oSQLServer As SQLDMO.SQLServer
Dim oSqldb As SQLDMO.Database
Dim oSqldf As SQLDMO.DBFile
Dim oSqllf As SQLDMO.LogFile
'Object Instantiation
Set oSqldb = CreateObject("SQLDMO.Database")
Set oSqldf = CreateObject("SQLDMO.DBFile")
Set oSqllf = CreateObject("SQLDMO.LogFile")
'Business Rules to determine names
sCustomerID = Left(sCustomerName, 6)
sDBName = sCustomerID & Left(sSurveyName, 5)
sDFName = Left(sCustomerID, 4) & Left(sSurveyName, 4) & ".mdf"
sLFName = Left(sCustomerID, 4) & Left(sSurveyName, 4) & ".ldf"
'Set Database Name property
oSqldb.Name = sDBName
'Business Rule to ensure that database is created
'on the drive with the most space
Set oSQLServer = oApp.SQLServers.ItemByID(lConnID)
sDriveAndPath = GetDriveWithMostSpace(lConnID) & "surveydat\"
'Set DBFile properties
oSqldf.Name = sDFName
oSqldf.PhysicalName = sDriveAndPath & sDFName
oSqldf.Size = 5
oSqldf.FileGrowthType = SQLDMOGrowth_Percent
oSqldf.FileGrowth = 20
oSqldf.MaximumSize = 40
'Set LogFile properties
oSqllf.Name = sLFName
oSqllf.PhysicalName = sDriveAndPath & sLFName
oSqllf.Size = 2
oSqllf.FileGrowthType = SQLDMOGrowth_Percent
oSqllf.FileGrowth = 20
oSqldf.MaximumSize = 40
'Add DBFile to the PRIMARY filegroup
oSqldb.FileGroups("PRIMARY").DBFiles.Add oSqldf
'Add the LogFile to the LogFiles collection
oSqldb.TransactionLog.LogFiles.Add oSqllf
'Add the Database to the Databases collection.
'At this point, the database is created.
oSQLServer.Databases.Add oSqldb
'Return the name of the database
Create = oSqldb.NameEnd Function
Private Function GetDriveWithMostSpace(ByVal lConnID As Long) As String Dim oQR As SQLDMO.QueryResults
Dim i As Integer
Dim sLargest As String
Dim lAmountLowFree As Long
Dim lAmountHighFree As Long
Dim oSQLServer As SQLDMO.SQLServer Set oSQLServer = oApp.SQLServers.ItemByID(lConnID)
Set oQR = oSQLServer.EnumAvailableMedia(SQLDMOMedia_FixedDisk)
sLargest = oQR.GetColumnString(1, 1)
lAmountLowFree = oQR.GetColumnLong(1, 2)
lAmountHighFree = oQR.GetColumnLong(1, 3) For i = 2 To oQR.Rows
If oQR.GetColumnLong(i, 3) > lAmountHighFree Then
'Keep track of which has the highest high order value
sLargest = oQR.GetColumnString(i, 1)
lAmountHighFree = oQR.GetColumnLong(1, 3)
ElseIf oQR.GetColumnLong(i, 3) = lAmountHighFree Then
'If the high order value was the same then determine
'the low order value
If oQR.GetColumnLong(i, 2) > lAmountLowFree Then
sLargest = oQR.GetColumnString(i, 1)
lAmountLowFree = oQR.GetColumnLong(i, 2)
End If
End If
Next GetDriveWithMostSpace = sLargestEnd Function这个只是创建数据库的文件,但是其中有部分的参数我不太了解还有我也查询了sql2000中的帮助中
通过sqldmo creater database 但是好象代码不能够通过
请指点主要对于创建数据库所必须的参数不了解Dim oDatabase As New SQLDMO.Database
Dim oDBFileData As New SQLDMO.DBFile
Dim oLogFile As New SQLDMO.LogFileoDatabase.Name = "Northwind"' Define the PRIMARY data file.
oDBFileData.Name = "NorthData1"
oDBFileData.PhysicalName = "c:\program files\microsoft sql server\mssql\data\northwnd.mdf"
oDBFileData.PrimaryFile = True' Specify file growth in chunks of fixed size for all data files.
oDBFileData.FileGrowthType = SQLDMOGrowth_MB
oDBFileData.FileGrowth = 1oDatabase.FileGroups("PRIMARY").DBFiles.Add oDBFileData' Define the database transaction log.
oLogFile.Name = "NorthLog1"
oLogFile.PhysicalName = "c:\program files\microsoft sql server\mssql\data\northwnd.ldf"
oDatabase.TransactionLog.LogFiles.Add oLogFile' Create the database as defined. Note: Create and connect of SQLServer
' object used is not illustrated in this example.
oSQLServer.Databases.Add oDatabase