Results 1 to 1 of 1

Thread: Can't Set Userid and Password to create dsn

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2000
    Location
    Over There
    Posts
    522

    Can't Set Userid and Password to create dsn

    I'm trying to create a dsn, but whenever I try to pass the uid or pwd arguments, it craps out. Can someone tell me the correct syntax please. I've tried various other pieces of code, and they all fail when trying to set the userid or password.

    I'm using VB6 on windows 2000


    Public Sub CreateDSN(Name As String, Database As String, Description As String)
    #If Win32 Then
    Dim intRet As Long
    #Else
    Dim intRet As Integer
    #End If
    Dim strDriver As String
    Dim strAttributes As String

    'Set the driver to SQL Server because it is most common.
    strDriver = "SQL Server"
    'Set the attributes delimited by null.
    'See driver documentation for a complete
    'list of supported attributes.
    strAttributes = "SERVER=pubnts01" & Chr$(0)
    strAttributes = strAttributes & "DESCRIPTION=" & Description & Chr$(0)
    strAttributes = strAttributes & "DSN=" & Name & Chr$(0)
    strAttributes = strAttributes & "DATABASE=" & Database & Chr$(0)
    strAttributes = strAttributes & "NETWORK=dbmssocn" & Chr$(0)
    strAttributes = strAttributes & "TRUSTED_CONNECTION=no" & Chr$(0)
    intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_SYS_DSN, _
    strDriver, strAttributes)
    strAttributes = ""
    strAttributes = strAttributes & "DSN=" & Name & Chr$(0)
    strAttributes = strAttributes & "UID=tcpadmin" & Chr$(0)
    strAttributes = strAttributes & "PWD=sql407" & Chr$(0)
    intRet = SQLConfigDataSource(vbAPINull, ODBC_CONFIG_SYS_DSN, strDriver, strAttributes)
    MsgBox intRet
    'strAttributes = strAttributes & "UID=tcpadmin" '& Chr$(0)
    'strAttributes = strAttributes & "PWD=sql407" & Chr$(0)


    End Sub
    Last edited by Dalceon; Oct 31st, 2001 at 09:42 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width