Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2008
    Posts
    2

    Unanswered:

    i resive a error when i run script below i vbscript
    What is wrong??

    Function InstallDB()

    Const HKEY_CLASSES_ROOT = &H80000000
    Const HKEY_CURRENT_USER = &H80000001
    Const HKEY_LOCAL_MACHINE = &H80000002
    Const HKEY_USERS = &H80000003
    Const HKEY_CURRENT_CONFIG = &H80000005


    Dim strComputer
    Dim objRegistry
    Dim strKeyPath
    Dim strValueName
    Dim strValue
    Dim arrValues
    Dim intValue
    Dim strpath
    Dim strpath2
    Dim strDBServerName
    Dim objSQLServer


    strComputer = "."

    Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default: StdRegProv")

    'Get String value
    strKeyPath = "Software\test"
    strValueName = "PATH2"
    objRegistry.GetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, strValue

    strpath = strValue & "Data\test_Data.mdf , " & strValue & "Data\test_log.ldf"
    strDBServerName = "."
    Set objSQLServer = CreateObject("SQLDMO.SQLServer")
    objSQLServer.LoginSecure = False 'sql authetication
    objSQLServer.Connect strDBServerName & "\test", "sa", "test" MsgBox (strpath)
    objSQLServer.AttachDB "test", strpath
    End Function
    Last edited by balcando; 01-31-08 at 16:42.

  2. #2
    Join Date
    Jun 2004
    Location
    Long Island
    Posts
    696
    Looks like a path needs to be wrapped in quotes somewhere, i.e. c:\Program Files.

  3. #3
    Join Date
    Jan 2004
    Location
    In a large office with bad lighting
    Posts
    1,040
    Why would VB script be in the SQL Server forum?

    Oh ... I know ... if something goes wrong it must be the database!

    -- This is all just a Figment of my Imagination --

  4. #4
    Join Date
    Jan 2008
    Posts
    2
    this is how i solved the problem

    strpath = "[" & strValue & "Data\FKB_Data.mdf] , [" & strValue & "Data\FKB_log.ldf]"

  5. #5
    Join Date
    Aug 2005
    Posts
    75
    Quote Originally Posted by tomh53
    Why would VB script be in the SQL Server forum?

    Oh ... I know ... if something goes wrong it must be the database!

    well, sql IS in there someplace. That's like when our helpdesk decides to assign a ticket to me to fix an html issue in one of our web apps. I mean the back end is SQL Server, so it must be a database problem, right?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •