如何避免SQL RequestError:“多部分标识符…不能被绑定”?

我正在尝试向SQL Server表中插入string时收到SQL RequestError。 string是com.softek.ofxclmobile.patriotfcu 。 我认为,string中的时段正在抛出某种红旗,它是对某个对象某个属性的引用,或者是沿着这些线条的东西。 我正在使用该请求的mssql节点模块。

 let myObj = { Date: '2015-06-22', PackageName: 'com.softek.ofxclmobile.patriotfcu' } let date = myObj['Date'] let pName = myObj['PackageName'] request.query('insert into myTable ([DATE],[PackageName]) values (' + date + ',' + pName + ')) 

我还没有find任何关于试图避免使用点符号的任何事情,但是我发现了一些相反的情况,试图进入符号。 我也看了,但没有RegExp关键字保持一段时间字面上的一段时间。

确切的错误:

 REQ ERROR { [RequestError: The multi-part identifier "com.softek.ofxclmobile.patriotfcu" could not be bound.] name: 'RequestError', message: 'The multi-part identifier "com.softek.ofxclmobile.patriotfcu" could not be bound.', code: 'EREQUEST', number: 4104, lineNumber: 1, state: 1, class: 16, serverName: 'PFCUAPPDEV01', procName: '' } 

你可以使用双引号来包装SQL

 request.query("insert into myTable ([DATE],[PackageName]) values ('" + date + "','" + pName + "')") 

为了安全起见,您可能需要使用两个单引号replacepName中的任何单引号