Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Data Source In Access 97

Status
Not open for further replies.

withoutaclue

Programmer
Aug 28, 2002
31
0
0
GB
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") 'creates ODBC data source

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,
 
Hello.

Why not create a data source with the connection information in Control Panel, and give it a name, then just refer to it in your connection string?

Regards,
Mr Big
 
Because the program is going to be used for many users on many different machines, so rather than configue each machine individualy it was ment to be easier to do it in access module.

Plus that how the Boss wants it done
Any ideas???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top