简体   繁体   English

直通 SQL 通过 MS Access 查询

[英]Passthrough SQL Query via MS Access

Currently, I have two separate SQL Server instances that I am querying using pass-through SQL queries via a form in Microsoft Access.目前,我有两个单独的 SQL 服务器实例,我通过 Microsoft Access 中的表单使用传递 SQL 查询进行查询。

The queries to SERVER1 work every time without fail.对 SERVER1 的查询每次都能正常工作。 I'd say about 80% of the time the queries to SERVER2 don't work after Access has been closed and re-opened until I go in and "modify" the OBDC connection string and save the query.我会说大约 80% 的时间在 Access 关闭并重新打开后对 SERVER2 的查询不起作用,直到我进入 go 并“修改”OBDC 连接字符串并保存查询。 I have quotes around modify because if I edit one character in the string and re-add it and then save, it usually starts to work again (but not always), even though the string hasn't changed.我在 modify 周围加了引号,因为如果我编辑字符串中的一个字符并重新添加它然后保存,它通常会再次开始工作(但并非总是如此),即使字符串没有改变。 And once it works it will continue to work until once again Access is closed.一旦它工作,它将继续工作,直到再次关闭 Access。

It's usually one of three errors, here are two of them and the third error which I get less frequently is that the login is incorrect:它通常是三个错误之一,这里是其中两个,我不太常见的第三个错误是登录不正确:

错误 1

错误 2

The OBDC connection string is as follows (for what it's worth I also tried ODBC Driver 17 for SQL Server and got the same results): OBDC 连接字符串如下(值得我还尝试了 SQL 服务器的 ODBC Driver 17 并得到相同的结果):

ODBC;Description=SERVER2 PASSTHROUGH;DRIVER=ODBC Driver 11 for SQL Server;SERVER=SERVER2;UID=Test;PWD=Password;DATABASE=MyDB;LANGUAGE=us_english;ApplicationIntent=READONLY; ODBC;Description=SERVER2 PASSTHROUGH;DRIVER=用于 SQL 服务器的 ODBC 驱动程序 11;SERVER=SERVER2;UID=Test;PWD=Password;DATABASE=MyDB;LANGUAGE=us_english;ApplicationIntent=

How do I go about solving this problem?我该如何解决这个问题? Also, I am willing to provide any clarifying information.此外,我愿意提供任何澄清信息。

Thanks!谢谢!

Thanks to Alex for the reply.感谢亚历克斯的回复。

Alex recommended going to SQLCMD Unable to complete login process due to delay in opening server connection . Alex 建议去SQLCMD Unable to complete login process due to delay in opening server connection I should have been more scientific but I used a shotgun approach... I set my shared memory to disabled, as well as increased the connection timeout and command timeouts.我应该更科学一点,但我使用了霰弹枪方法......我将我的共享 memory 设置为禁用,并增加了连接超时和命令超时。

This then produced a new error for me similar to the one here No process is on the other end of the pipe (SQL Server 2012) .然后这对我产生了一个新错误,类似于No process is on the other end of the pipe (SQL Server 2012)

As many of the comments suggested, my SQL server was set to SQL Server and Windows Authentication mode, I changed it to Windows Authentication mode, and then back to SQL Server and Windows Authentication mode, and restarted my SQL server. As many of the comments suggested, my SQL server was set to SQL Server and Windows Authentication mode, I changed it to Windows Authentication mode, and then back to SQL Server and Windows Authentication mode, and restarted my SQL server.

And for now, my problem has not shown up through multiple MS Access restarts and a few PC restarts as well for good measure.就目前而言,我的问题还没有通过多次 MS Access 重新启动和几次 PC 重新启动来解决。 Fingers crossed.手指交叉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM