当尝试从c ++执行sql server中的存储过程时,我得到ce = {DB_E_ERRORSINCOMMAND}
c ++代码
pCom->Execute(NULL,NULL,adCmdStoredProc);
从命令对象执行..
存储过程看起来像这样
create PROCEDURE [dbo].[InsertTicketDetails]
AS
BEGIN
DECLARE @inputXml XML;
SET NOCOUNT ON
set @inputXml = '<Record><studentid>143</studentid></Record>';
INSERT INTO dbo.sample (studentid)
SELECT
@inputXml.value( 'studentid[1]', 'int' ) AS studentid
FROM @inputXml.nodes('/Record') a(y)
END
如果在没有xml正常工作的情况下完成插入,则使用xml完成inserstion。我认为xml存在问题,或者我们无法从c ++访问sql server的xml功能?
答案 0 :(得分:1)
错误不在ADO中,而是在返回NULL的SQL中。我怀疑dbo.sample(studentid)不允许空值。
将insert语句更改为:
INSERT INTO dbo.sample (studentid)
SELECT
@inputXml.value( '(/Record/studentid)[1]', 'int' ) AS studentid
或
INSERT INTO dbo.sample (studentid)
SELECT
@inputXml.value( '(//studentid)[1]', 'int' ) AS studentid
FROM @inputXml.nodes('/Record') a(y)