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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQLserver/Access: creating a dsn from code problems

Status
Not open for further replies.

yannou

IS-IT--Management
Apr 30, 2003
6
FR
When I first create a dsn from code in access, and after when I link a view, it cause ODBC/Sqlserver ask for a Primary Key.
I want to know if there is a way to select the key from code, to prevent the opening of a dialog (for automatisation issues).

Here is the code for creating the dsn :

str = "Description=SQL Server " & vbCr & _
"Network=DBMSSOCN" & vbCr & _
"Address=" & ip & "," & port " & vbCr & _
"Server=mydsn" & vbCr & _
"Database=" & sql_serv_base & vbCr & vbCr
DBEngine.RegisterDatabase "mydsn", "SQL Server", True, str


and this is for creating the link :

DoCmd.TransferDatabase acLink, "Base de données ODBC", _
"ODBC;DSN=mydsn;UID=" & login & ";PWD=" & pwd &
";LANGUAGE=français;" & "DATABASE=" & sql_serv_base, _
acTable, !alias_, !alias_, True

after this command it ask for a primary key

Sorry for my english I'm french :)

Thanks
 
The easy thing to do is to create a Unique Index in SQL Server so that Access can be satisfied it can update records correctly without violating record integrity (the reason it is asking for the Primary Key).

Sorry about the big words... My French isn't good enough to translate :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top