我可以利用
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 Const ODBC_ADD_SYS_DSN = 4
Public Function CreateDSN(Driver As String, Attributes As String) As Boolean
CreateDSN = SQLConfigDataSource(0&, ODBC_ADD_SYS_DSN, Driver, Attributes)
End Function
Public Function CreateSQLServerDSN(DSNName As String, _
ServerName As String, Database As String, username As String) As Boolean
Dim sAttributes As String
sAttributes = "DSN=" & DSNName & Chr(0)
sAttributes = sAttributes & "Server=" & ServerName & Chr(0)
sAttributes = sAttributes & "Database=" & Database & Chr(0)
'但使用者要如何加入此參數列?????
CreateSQLServerDSN = CreateDSN("SQL Server", sAttributes)
End Function
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 Const ODBC_ADD_SYS_DSN = 4
Public Function CreateDSN(Driver As String, Attributes As String) As Boolean
CreateDSN = SQLConfigDataSource(0&, ODBC_ADD_SYS_DSN, Driver, Attributes)
End Function
Public Function CreateSQLServerDSN(DSNName As String, _
ServerName As String, Database As String, username As String) As Boolean
Dim sAttributes As String
sAttributes = "DSN=" & DSNName & Chr(0)
sAttributes = sAttributes & "Server=" & ServerName & Chr(0)
sAttributes = sAttributes & "Database=" & Database & Chr(0)
'但使用者要如何加入此參數列?????
CreateSQLServerDSN = CreateDSN("SQL Server", sAttributes)
End Function
請先 登入 以發表留言。