473,382 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

connecting Access front-end to SQLServer back-end via code

I am in the early stages of converting a back-end .mdb file to
SqlServer - my first attempt! I have used Data Transformation Services
to copy all the tables to SqlServer into a database named JobSystem.
When using Enterprise Manager, I can see all the data. So far, so
good!!
From within the front-end I want to link my tables and have tried the

following code:

For Each tdf In CurrentDb.TableDefs
If (tdf.Attributes = dbAttachedODBC) Or (tdf.Attributes =
dbAttachedTable) Then
Dim aTable As DAO.TableDef
Dim tableName
tableName = tdf.Name
Set aTable = CurrentDb.TableDefs(tableName)
If Err.Number = 0 Then ' found existing tabledef
'On Error GoTo nextTable
CurrentDb.TableDefs.Delete tableName
CurrentDb.TableDefs.Refresh
Else
Err.Clear
End If
Set aTable = CurrentDb.CreateTableDef(tableName)
aTable.Connect = "ODBC;DataBase=JobSystem; DRIVER=SQLServer; " _
& "SERVER=(local);APP=Microsoft Data Access Components; " _
& "Trusted_Connection=Yes;"
aTable.SourceTableName = tableName
CurrentDb.TableDefs.Append aTable
nextTable:
End If
Next tdf

All the tables link correctly but unfortunately they are read-only !!
I assume that there must be something wrong with the connection string.
But what, I do not know.

If, instead of using the code, I use 'Get external data|Link tables
....' from the File menu everything works well and the tables are
updateable. However all the links are now given names such as
dbo_MyTable instead of simply MyTable; and during the linking process I
am asked' for each table' to select a field in order 'To ensure
data integrity and to update records, you must choose a field that
uniquely identifies each record'

When I have linked the tables in this way, the connection string (shown
in the properites of the table) is the same as when I use the above
code (except that the table to which it is linked is dbo.MyTable)

How can I make the link with code to get tables that are updateable?

Mar 12 '06 #1
2 2328
On 12 Mar 2006 09:53:37 -0800, "Jim Devenish"
<in***************@foobox.com> wrote:

Attached tables are readonly if the tables don't have a primary key.
Adding a primary key to each table is a good design practice anyway.

-Tom.
<clip>

All the tables link correctly but unfortunately they are read-only !!
I assume that there must be something wrong with the connection string.
But what, I do not know.

<clip>

Mar 12 '06 #2

Tom

Many thanks for the help. How did I miss that? Should have read the
small
print.

My Access tables do have primary keys and assumed that DTS would copy
them
into SQLServer, even though I did not appreciate their full
significance.

I now realise that I was using the DTS wizard but am now exploring the
full DTS
package. I want to be able to create SQLServer tables with primary keys
(as in
the Access tables) without having to go the design of every one of them
to re-
introduce them.

Thanks again
Jim Devenish

*** Sent via Developersdex http://www.developersdex.com ***
Mar 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Morgan | last post by:
I have Enterprise Manager on my local machine. For the last twelve months it has been connecting without problem to my online SQL Server database provided by my ISP. Three weeks ago the ISP...
1
by: Mal Reeve | last post by:
Hello. I recente created a database on our website to gather survey responses. I did this through Front Page with made the process extreemly easy. I finish up with a database in a folde on...
12
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed...
13
by: Joner | last post by:
Hello, I'm having trouble with a little programme of mine where I connect to an access database. It seems to connect fine, and disconnect fine, but then after it won't reconnect, I get the error...
5
by: bill | last post by:
I am having difficulties connecting to a remote Sql server database in VB.net. Lets say my remote server is found at 255.255.255.255 and its name is MyServer. The database is called MyDatabase....
4
by: kthiagar | last post by:
Hi I am trying to connect to a password protected access file from VB.NET. I have no problem in connecting to Access, if I remove the password. This is what I am doing: In the server explorer,...
3
by: Laurence | last post by:
Hi there, Does somebody know the efficent way to connect DB2/400? Through iSeries Access ODBC/OLEDB driver or DB2 Connect? Which will more fast and efficent? In addition, does DB2 Connect use...
9
by: RvGrah | last post by:
After much hair-pulling, I've finally found the answer to a problem that many are fighting with, difficulty connecting from Sql 2005 Server Management or VS2005 to a remote Sql Server running Sql...
3
by: Chris | last post by:
Don't know if there is a simple solution for this one or not. When running SQL server on a machine with 2000 loaded and the complete SQL package I don't have any issues. Now I'm trying to login...
2
by: steve | last post by:
Hi All Has anybody had experience connecting to SQL server 2005 on a remote site via VPN A client has a warehouse in each capital city in Australia and wants to have them all record sales etc...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.