#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Posts
    104
    Rep Power
    5

    Connect to sql server 2005 via text file( with .ini extension)


    file settings.ini

    [Connection_String]
    Driver={SQL Server}
    Server=113.160.248.114,1434
    Database=Northwind
    Uid=xyz
    Pwd=123
    Trusted_Connection=yes



    Dim MyConnect As New ADODB.Connection
    Dim MyRecSet As New ADODB.Recordset
    Dim strSQL As String
    Dim COMMFilePath As String
    COMMFilePath = GetINISetting("COMM", "FilePath", Application.Path & " ")
    MyConnect.Open _
    "Driver={SQL Server};" & _
    "Server = Trim(GetINISetting("Connection_String", "Server", Application.Path & " SETTINGS.INI"));" & _
    "Database = Trim(GetINISetting("Connection_String", "Database", Application.Path & " SETTINGS.INI"));" & _
    "Uid = Trim(GetINISetting("Connection_String", "Uid", Application.Path & " SETTINGS.INI"));" & _
    "Pwd = Trim(GetINISetting("Connection_String", "Pwd", Application.Path & " SETTINGS.INI"));" & _
    "Trusted_Connection = Trim(GetINISetting("Connection_String", "Trusted_Connection", Application.Path & " SETTINGS.INI"));"

    My code above fails, do not work or who have read the example text file. Ini shared with me. thanks
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,453
    Rep Power
    4539
    Use your debugger to look at the resulting string in COMMFilePath
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester

IMN logo majestic logo threadwatch logo seochat tools logo