Avatar of Karen Schaefer
Karen SchaeferFlag for United States of America

asked on 

DSN Less Connection to SQL table in Access

I am trying to connect to an SQL table in Access using DSNLess Connection string for Linked table.  Note multiple user will be access this database so setting ups a DSN connection for a linked table will not be sufficient.  What am I doing wrong:

Server name = SQL-NWSS-007\AUB1
Database name = FTVI_DBMS
SQL Table Name dbo.TA_AirplaneInfo

Public Function LinkODBCTable()

Dim db As Database, tdf As TableDef
Dim strConnect As String
strConnect = "ODBC;SERVER=MySQLServer;UID=sa;DRIVER=SQL" & _
"Server;DATABASE=SQL-NWSS-007\AUB1\FTVI_DBMS"
Set db = CurrentDb()
Set tdf = db.CreateTableDef(Name:="dbo_TA_AirplaneInfo", Attributes:=dbAttachSavePWD, SourceTableName:="dbo.TA_AirplaneInfo", Connect:=strConnect)
db.TableDefs.Append tdf

End Function

K
Microsoft Access

Avatar of undefined
Last Comment
Jim P.
ASKER CERTIFIED SOLUTION
Avatar of Jim P.
Jim P.
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Karen Schaefer

ASKER

Using my above mentioned server name and database name - how do I modify your code and do I still need to create the actual DSN in DATA Source Admin.?

Karen
Avatar of Karen Schaefer

ASKER

I got it, however, how to I make sure the linked table is writable?  My  current linked table doesnot allow to add new records - WHY?

K
Avatar of Jim P.
Jim P.
Flag of United States of America image

If you don't have an index/primary key(s) on the SQL Server tables, the tables, by default, will be read only. And after you do the index/PK, you will have to re-attach the table to get it to be an editable table.
Avatar of Jim P.
Jim P.
Flag of United States of America image

Almost forgot:

Glad to be of assistance. May all your days get brighter and brighter.
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo