![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
#4
| |||
| |||
|
|
I want to do the same thing. But I only have a mdb file. Is it easy to convert MDB to ADP? |
#5
| |||
| |||
|
#6
| |||
| |||
|
#7
| |||
| |||
|
|
I connect my Access database to a SQL Server in two different ways: 1 with ADO such as: Dim theConnectionString theConnectionString = Driver=SQL Server; Server=Server \TRUTIMEV3;Database=Intelligent;User ID=xxx;Password=xxx; Dim rec As ADODB.Recordset Set rec = New ADODB.Recordset Dim theSQLString theSQLString = "Select * From [Cost Centres] Where CC_Code = '" & theJobDigits & "'" rec.Open theSQLString, theConnectionString, adOpenStatic, adLockOptimistic 2 with DAO such as: Dim theViewName theViewName = "aView" Dim aTable As DAO.TableDef Set aTable = CurrentDb.CreateTableDef(theViewName) aTable.Connect = ODBC;APP=Microsoft Data Access Components;Trusted_Connection=Yes;Driver=SQL Server; Server=Server \TRUTIMEV3;Database=Intelligent;User ID=xxx;Password=xxx; |
#8
| |||
| |||
|
|
Jim Devenish wrote: I connect my Access database to a SQL Server in two different ways: 1 *with ADO such as: * * Dim theConnectionString * * theConnectionString = Driver=SQL Server; Server=Server \TRUTIMEV3;Database=Intelligent;User ID=xxx;Password=xxx; * * Dim rec As ADODB.Recordset * * Set rec = New ADODB.Recordset * * Dim theSQLString * * theSQLString = "Select * From [Cost Centres] Where CC_Code = '" & theJobDigits & "'" * * rec.Open theSQLString, theConnectionString, adOpenStatic, adLockOptimistic 2 *with DAO such as: * * Dim theViewName * * theViewName = "aView" * * Dim aTable As DAO.TableDef * * Set aTable = CurrentDb.CreateTableDef(theViewName) * * aTable.Connect = ODBC;APP=Microsoft Data Access Components;Trusted_Connection=Yes;Driver=SQL Server; Server=Server \TRUTIMEV3;Database=Intelligent;User ID=xxx;Password=xxx; "Trusted_Connection=Yes" means that the current network credentials are used to establish the connection. Since the database requires a user name and password, you should remove the Trusted_connection attribute or set it to No. You should use the ODBC names for the user and password attributes: UID and PWD instead of "User ID" and "Password". Also, shouldn't that connection string be quoted? Like this: * * aTable.Connect = "ODBC;APP=Microsoft Data Access" & _ "Components;Driver=SQL Server; Server=Server" & _ "\TRUTIMEV3;Database=Intelligent;UID=xxx;PWD=xxx;" PS. I know you say it's been "working for years", but it's really not a good idea to use implicit ADO connections. The line: *rec.Open theSQLString, theConnectionString ... causes ADO to open a connection object behind the scenes (implicitly), an object over which you have no control. If you are opening multiple recordsets in your application, the result could well be that a separate open connection to the database will exist for each recordset you have opened, each of which consumes resources both on the client machine as well as on the database server. Eventually, the point could be reached where your database server refuses new connections. Best practice is to explicitly create a connection object and use that to open your recordsets: dim cn as adodb.connection set cn=new adodb.connection cn.open "your connection string" ... rec.Open theSQLString, cn, ... Close the connection object when finished using it so that it goes back into the pool of connections that can be re-used. Also, you should get away from using ODBC with ADO as it creates an extra software layer. Use the native OLE DB provider for SQL that is relevant for the version of sql server you are connecting to. You can find the relevant OLE DB connection strings here:http://www.connectionstrings.com/ -- HTH, Bob Barrows |
![]() |
| Thread Tools | |
| Display Modes | |
| |