SQL Server与jQuery和节点js的连接 [英] SQL Server connection with jQuery and node js

查看:81
本文介绍了SQL Server与jQuery和节点js的连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用节点js连接到只有Windows身份验证的SQL Server。数据库存储在集中式计算机上。

I am using node js to connect to a SQL Server that has only Windows authentication. The database is stored on a centralised machine.

数据库返回一些我放在某个地址的json数据( http://10.2.9.208:8081/me )。这是我PC的地址,即( https:// localhost / me ),我使用jQuery调用检索它。

The database returns some json data which I place at some address (http://10.2.9.208:8081/me). This is the address of my PC i.e, (https://localhost/me) and I retrieve it using a jQuery call.

这个jQuery调用是从一个html页面调用来检索jsonp格式的数据,以避免跨源问题。

This jQuery call is made from a html page to retrieve jsonp formatted data to avoid cross origin problems.

这是我在页面中的jQuery调用index12.html

This is my jQuery call in a page index12.html

$.get("http://10.2.9.208:8081/me?callback=?", function (data) {

        dataset_module_errors = data;
    });

连接字符串位于页面app.js

The connection strings are in a page app.js

我用来连接数据库的连接字符串是

My connection string which I used to connect with database was

var config = {
server: '10.2.12.153',                          
database: 'DFMProAnalyticsCopy',       // my table is within this server
port: 1433                             // default port number
};

这会引发错误'LOGIN ERROR',因为它认为是用户&密码为'' - >空字符串。

This throws an error 'LOGIN ERROR' as it considered user & password as '' -> null strings.

所以我最终将此用于Windows身份验证

So I eventually used this for windows authentication

var config = 
"Driver={SQL Server Native Client 11.0};
Server=10.2.12.153,1433;
Database=DFMProAnalyticsCopy;
Trusted_Connection={Yes}";

现在抛出两个错误 - >

Now this throws two errors ->


  1. ConnectionError:未知驱动程序SQL Server Native Client 11.0!

  2. 获取 http://10.2.9.208:8081/me?callback= ? 500(内部服务器错误)

  1. ConnectionError: Unknown driver SQL Server Native Client 11.0!
  2. GET http://10.2.9.208:8081/me?callback=? 500 (Internal Server Error)

我已提到如何查找连接字符串的ODBC驱动程序名称?以查找驱动程序名称并对其进行了两次验证。

I have referred to How to find the ODBC driver name for a connection string? to find the driver name and have verified it twice.

当我通过JQuery调用访问我的PC上安装的本地数据库时,所有这一切都完美无缺。我的PC上有用户SQL身份验证.Windows身份验证提供错误

All of this has been working perfectly fine when I accessed my local database installed on my PC through the JQuery call. I had user SQL Authentication on my PC.Windows authentication gives the error

login failed for user '' 

我在做错了访问中央数据库。

I have done some mistake in accessing the central DB.

请指导我完成。

编辑1:由于这是Windows身份验证,我没有用户名或密码

EDIT 1: Since this is Windows authentication, I do not have a username or password

推荐答案

OdbcConnection的表单连接字符串是

Form Connection-string for OdbcConnection is

Driver = {SQL Server} ; Server = 10.0.0.1; Database = db_alias; Uid = db_login; Pwd = db_passw

Driver={SQL Server};Server=10.0.0.1;Database=db_alias;Uid=db_login;Pwd=db_passw

不要更改驱动程序参数。
并且感谢Suchitra Iyer,本地服务器连接字符串是

Do not change driver parametr. And thanks Suchitra Iyer, for local server connection-string is

Server = {10.2.9.208}; Database = trialdb; Uid =; Pwd =

"Server={10.2.9.208};Database=trialdb;Uid=;Pwd="

这篇关于SQL Server与jQuery和节点js的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆