withoutaclue
Programmer
I need to create a sql ODBC data sourse in access, so that when you load up the access aplication file it automatiaclly creates an ODBC conection.
This is the code that I got from the internet.
Function CreateSQLDataSource(SourceToCreate As String, ServerName As String, DatabaseName As String) As Boolean
'
' Programmatically creates a datasource in ODBC.INI. You can verify in ODBC Administrator program.
'
' Arguments:
' SourceToCreate Arbitrary name to give the datasource
' ServerName The name of the server where the database is located
' DatabaseName The name of the database
'
' Returns: TRUE = Success; FALSE = Failure
'
' You can add more arguments for other options
'
Dim Attribs As String, CR As String
CR = Chr$(13) ' will not work if you use chr$(13) & chr$(10)
Attribs = "Description=" & SourceToCreate & " Data Source" & CR
Attribs = Attribs & "OemToAnsi=No" & CR
Attribs = Attribs & "Server=" & ServerName & CR
Attribs = Attribs & "Database=" & DatabaseName
On Error Resume Next
DBEngine.RegisterDatabase SourceToCreate, "SQL Server", True, Attribs
If err.Number = 0 Then
CreateSQLDataSource = True
Else
CreateSQLDataSource = False
End If
End Function
And I have called the funtion from with in anouth function (startup)
Call CreateSQLDataSource("SectorMacroData", "midas", "SectorMacroData"
The problem is, I don’t know how to cahnge other feature of the ODBC from with in access, as I don’t want to have to change it via controll panel ect
The features I need code for is to change the following:
Login needs to = NT server, Client Config needs to = Multiprotocol
Sorry for the long message,