且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从Windows将Rails应用程序连接到SQL Server 2005

更新时间:2023-02-06 22:34:51

这是一个示例DSN,它使用Windows用户帐户连接到数据库(***是使用域登录的公司网络)

this is a sample DSN, that connects to the database using the Windows user account (best when corporate network with domain login)

Provider=SQLOLEDB;Data Source=MyServer\MyInstance;Integrated Security=SSPI;Initial Catalog=MyDatabase;Application Name=My Application Name that will show up in the trace

因此这将OLEDB提供程序用于SQL Server.也可以使用SQLNCLI,但尚未在ODBC上尝试过.实际上,此DSN尚未经过充分测试(必须等待我的管理员为我提供必要的权限),但是它是从使用SQLNCLI作为提供程序的工作脚本中复制的.数据源是服务器,如果它具有命名实例,则必须指定它,因此它只能是ServerServer\Instance. Integrated Security=SSPI告诉您要使用Windows身份验证.否则,您可以使用UID=MyUser;PWD=MyPassword指定要使用的用户和密码. UID,用户,用户名,密码-我认为所有这些参数都有效.

So this uses the OLEDB provider for SQL Server. SQLNCLI can also be used, haven't tried it with ODBC. Actually this DSN isn't quite tested (have to wait for my admin to give me the necessary rights), but it was copied from a working script, that used SQLNCLI as the provider. The Data source is the server, and if it has a named instance, it has to be specified, so it's either just Server or Server\Instance. The Integrated Security=SSPI tells it you want to use Windows Authentication. Otherwise you specify the user and password to use using UID=MyUser;PWD=MyPassword. UID, User, Username, Password - I think all of these parameters work.

互联网上有一个很棒的网站,提供各种DSN样本,只是在任何地方都找不到.如果找到它,我会让你知道.

There is a great site over the internet that provides all kinds of DSN samples, just can't find it anywhere. If I find it, I will let you know.

如果Rails中没有任何提供程序,请检查Rails是否支持Windows组件对象模型(COM).如果可以的话,您甚至可以初始化ADODB.Connection COM类,并在其上使用ADO.

If you haven't got any provider in Rails, check out if Rails supports Windows Component Object Model (COM). And if it does, you can even initialize the ADODB.Connection COM class, work with ADO thereon.

啊,这是我正在谈论的站点: http://www.connectionstrings.com/

Ah, here is that site I was talking about: http://www.connectionstrings.com/