欲在安装该系统时自动在系统找寻找sqlserver,然后建立一数据库,然后建立表和视图和触发器,解决后再送50.

解决方案 »

  1.   

    呵呵,正在解决相似的问题,已经搞通寻找SQLSERVER,建立数据库,建军立表和视图,触发器没搞过,不知道怎么用,有什么好处,望来信探讨!
    MSN:[email protected],请先说明是VB。
    e妹:[email protected]
      

  2.   

    朋友们,可以介绍一下用法啊吗?贴段代码出来看看??MY QQ:3433590
      

  3.   

    我现在这里有一段代码大家可以参考,但是我其中部分参数不了解请大家解释。
    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
      

  4.   

    主要是 lConnID这个到底是个什么东西