因此,Im试图利用ODBC在SQ数据库中执行储存程序,但该错误又回来。
odbc_fetch_array() [function.odbc-fetch-array]:
SQL error: [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index,
SQL state S1002 in SQLGetData
这里的购买力平价部分,基本标准
...
$id = 240
$user = "user";
$password = "password";
$server = "server";
$database = "database";
$con = odbc_connect("SERVER=$server;
DRIVER=SQL Server;
DATABASE=$database",
$user,
$password);
$res = odbc_exec($con, "exec usp_GetRelatedToID $id ");
while($row = odbc_fetch_array($res)){
print_r($row);
}
这里的储存程序实际上很小而且容易。
CREATE PROCEDURE [dbo].[usp_GetRelatedToID]
@id int
AS
BEGIN
SET NOCOUNT ON;
SELECT AMENDMENT_ID, WDATE, ALTERATION, VER, REASON
FROM AMENDMENTS
WHERE AMENDMENT_ID = $id
END
表格
(Column_name) (Type) (Nullable)
AMENDMENT_ID int no
RAD_MAIN_ID int yes
WDATE datetime yes
USR_ID int yes
ALTERATION varchar yes
REASON varchar yes
VER int yes
Identity Seed Increment Not For Replication
AMENDMENT_ID 1 1 0
constraint_type constraint_name constraint_keys
PRIMARY KEY (non-clustered) aaaaaAMENDMENTS1_PK AMENDMENT_ID
www.un.org/Depts/DGACM/index_spanish.htm 令人感兴趣的是,如果我从程序上删除VER
栏,它不会回过错。
与此类似:
CREATE PROCEDURE [dbo].[usp_GetRelatedToID]
@id int
AS
BEGIN
SET NOCOUNT ON;
SELECT AMENDMENT_ID, WDATE, ALTERATION, REASON
FROM AMENDMENTS
WHERE AMENDMENT_ID = $id
END
谁能解释我在哪里做错,为什么会发生这种情况? I ve got 其它有相同错误的储存程序(有些也共用VER/code>,而I ve got 储存程序没有编号)。
I ve Trial different methods of fetching the data in PHP using odbc_prepare
and odbc_execute
with both query structure, {Call all wep_Getrelatedd ToID(?)}
, but that only given more wrong.
And for reasons I won t go into, I can t use mssql functions in PHP, ODBC is the only way I m allowed to connect and query.
www.un.org/Depts/DGACM/index_spanish.htm Oh, 执行平原(原始)的盘问,而不是在储存程序中,没有错误。
http://www.ohchr.org。
$stmt = odbc_prepare($con, "{CALL usp_GetRelatedToID($id)}");
$res = odbc_execute($stmt, array());
//or
$stmt = odbc_prepare($con, "{CALL usp_GetRelatedToID(?)}");
$res = odbc_execute($stmt, array($id));
两人都回过这一错误信息:
Warning: odbc_execute() [function.odbc-execute]:
SQL error: [Microsoft][ODBC SQL Server Driver]Cursor type changed,
SQL state 01S02 in SQLExecute