--通用聲明
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&          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
--聲明結束--開始創建
Private Sub Command1_Click()
Dim intRet As Long
Dim strDriver As String
Dim strAttributes As String'usamos el driver de SQL Server porque es el mas comun
strDriver = "SQL Server"
'Asignamos los parametros separados por null.
strAttributes = "SERVER=Server" & Chr$(0)
strAttributes = strAttributes & "DESCRIPTION=db_mis" & Chr$(0)
strAttributes = strAttributes & "DSN=Db_mis" & Chr$(0)
strAttributes = strAttributes & "DATABASE=db_mis" & Chr$(0)
strAttributes = strAttributes & "UID=sa" & Chr$(0)
strAttributes = strAttributes & "PWD=" & Chr$(0)
intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, strDriver, strAttributes)
If intRet Then
MsgBox "DSN成功!"
Else
MsgBox "DSN失敗!"
End If
End Sub
--結束創建
問題:
如果去掉
strAttributes = strAttributes & "UID=sa" & Chr$(0)
strAttributes = strAttributes & "PWD=" & Chr$(0)
則創建成功,否則不成功
請問現在我一定要把login id 和密碼加進去,如何加才能成功呢