开发者

Trouble resetting connection string in Access 2010

开发者 https://www.devze.com 2023-02-09 23:03 出处:网络
New to Access 2010.The following VBA code when run doesn\'t reset the connection string as expected.I\'m pretty sure this used 开发者_运维问答to work.What\'s wrong?

New to Access 2010. The following VBA code when run doesn't reset the connection string as expected. I'm pretty sure this used 开发者_运维问答to work. What's wrong?

CurrentDb.TableDefs("AccountNumber").Connect = "ODBC;Description=NativeClient;DRIVER=SQL Native Client;SERVER=server1;DATABASE=Expense;Trusted_Connection=Yes"
CurrentDb.TableDefs("AccountNumber").RefreshLink


I am not sure about that connection string. Which version of SQL Server are you using? You might like to try a connection string from http://www.connectionstrings.com/sql-server-2008#p3, for example, this works for me.

scn = "Driver={SQL Server Native Client 10.0};" & _
"Server=ServerName; Database=test;Trusted_Connection=yes;"
With CurrentDb
     .TableDefs(sLocalName).Connect = scn
     .TableDefs(sLocalName).RefreshLink
End with
0

精彩评论

暂无评论...
验证码 换一张
取 消