English 中文(简体)
[Microsoft][ODBC服务器司机][SQL服务器]
原标题:[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near =

我开始在一页上出现错误,正为解决这一问题而努力。 我在Stack Overflow上搜索了同样的错误信息,发现一些人也这样做,但解决办法与地雷有很大不同。 这是错误的信息:

M.Microsoft OLE DB ODBC司机错误 80040e14

[Microsoft][ODBC服务器司机][SQL服务器]Incorrect syntax near = 。

/test-page.asp, line 97

This related to this line on that .asp page:

set rsMainContact=oConn.execute 
    ("SELECT * FROM tbl_individual WHERE individual_id="&iMainContact)

现在,这方面的奇怪之处在于,该网页实际上正在输入正确的数据,它从表中获取它所需要的全部数据。 这就是为什么我不理解为什么会出现问题。

Also, when I run the query using the "SELECT * FROM tbl_individual WHERE individual_id="&iMainContact" statement in MSSQL, replacing &iMainContact for an actual variable, it works absolutely fine.

Does anyone have any idea why this error might be occurring?

如果你想要知道从哪里产生各种变数,那也是页上的一些相关代码:

SET rsOrganisationPendingOrganic=Server.CreateObject("ADODB.RecordSet")
rsOrganisationPendingOrganic.CursorType=3
rsOrganisationPendingOrganic.Open sSQL, oConn
iOrganisationPendingOrganicCount=rsOrganisationPendingOrganic.RecordCount

iMainContact=rsOrganisationPendingOrganic("organisation_maincontact")
问题回答

如果出现错误,你最有可能对iMainContact无价值:

SET rsOrganisationPendingOrganic=Server.CreateObject("ADODB.RecordSet") 
rsOrganisationPendingOrganic.CursorType=3

rsOrganisationPendingOrganic.Open sSQL, oConn
iOrganisationPendingOrganicCount=rsOrganisationPendingOrganic.RecordCount

iMainContact=rsOrganisationPendingOrganic("organisation_maincontact")

在执行失败的 s之前,你可以向屏幕书写 s:

Response.Write "SELECT * FROM tbl_individual WHERE individual_id=" & iMainContact
Response.End

我也同意1000%的 la2025,使用参数查询来防范sql injection





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签