Hello,
Please i need help with how to automatically create DSN for connection to MSSQL server with supplied username and password.
I have searched online and cant find anything that works.
The following code i have used worked if i am not supplying username and password, but i need the one that works with supplied username and password

Code:
'Constant Declaration
Private Const ODBC_ADD_DSN = 1               ' Add data source
Private Const ODBC_CONFIG_DSN = 2             ' Configure (edit) data source
Private Const ODBC_REMOVE_DSN = 3             ' Remove data source
Private Const vbAPINull As Long = 0            ' NULL Pointer

'Function Declare
#If Win32 Then

  Private Declare Function SQLConfigDataSource Lib "odbccp32.dll" _
      (ByVal hwndParent As Long, ByVal fRequest As Long, _
      ByVal lpszDriver As String, ByVal lpszAttributes As String) _
      As Long
#Else
  Private Declare Function SQLConfigDataSource Lib "ODBCINST.DLL" _
      (ByVal hwndParent As Integer, ByVal fRequest As Integer, ByVal _
      lpszDriver As String, ByVal lpszAttributes As String) As Integer
#End If


'//Add DSN
Private Sub Command1_Click()
  #If Win32 Then
    Dim intRet As Long
  #Else
    Dim intRet As Integer
  #End If
  Dim strDriver As String
  Dim strAttributes As String

  strDriver = "SQL Server"
  strAttributes = "SERVER=MSSQLSERVER1" & Chr$(0)
  strAttributes = strAttributes & "DESCRIPTION=Temp DSN" & Chr$(0)
  strAttributes = strAttributes & "DSN=DSN_TEMP" & Chr$(0)
  strAttributes = strAttributes & "DATABASE=MonoDB" & Chr$(0)
  strAttributes = strAttributes & "Trusted_Connection=true" & Chr$(0)
  
  'To show dialog, use Form1.Hwnd instead of vbAPINull.
  intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, _
      strDriver, strAttributes)
  If intRet Then
    MsgBox "DSN Created"
    Call TestDSNConnection("DSN_TEMP")
  Else
    MsgBox "Create Failed"
  End If

End Sub
Please help.