使用存储过程将数据插入表中的问题 [英] Problem on insertion data to table using storedprocedure

查看:82
本文介绍了使用存储过程将数据插入表中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友
我使用C#Windows应用程序使用storedprocedure将数据插入到sqltable中.从sqlcommand.ExecuteNonQuery()上的storedprocedurte获取结果时,它为存储过程返回-1.我认为这意味着数据已成功插入.但是在检查表时,表中没有数据.

Hi friends
I insert data to sqltable with storedprocedure using c# windows application. when getting result from storedprocedurte on sqlcommand.ExecuteNonQuery() it return -1 for stored procedure.I think this means data successfully inserted. but when checking table there is no data present in table. what could be the problem on this issue?

推荐答案

如果没有任何代码,很难说出来.但是,我仍然会尽力帮助您解决问题.通常,对于UPDATE,INSERT和DELETE语句,返回值是受命令影响的行数.当在要插入或更新的表上存在触发器时,返回值包括受插入或更新操作影响的行数以及受一个或多个触发器影响的行数.对于所有其他类型的语句,返回值是-1.如果发生回滚,则返回值也是-1."因此,请检查是否发生任何事务回滚.
有关更多详细信息,请参见以下链接.
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.executenonquery.aspx [ ^ ]
it''s difficult to tell without any code. But still i will try to help you to solve the issue."Usually,for UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. When a trigger exists on a table being inserted or updated, the return value includes the number of rows affected by both the insert or update operation and the number of rows affected by the trigger or triggers. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1." So please check, if any transaction rollback occured.
Refer the following link for more details.
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.executenonquery.aspx[^]


您可以尝试在管理器的编辑器窗口中运行存储过程中的代码并在其中玩耍.有点棘手,但可能有助于理解代码并找出问题所在.
You can try to run the code inside the stored procedure in management studio in an editor window and playing around. It''s a little bit tricky, but may help to understand the code and find out the problem.


检查表,sp字段以及您要发送的值...
或在sqlserver中触发查询
check table,sp fields and there values which u sending...
or fire your query in sqlserver


这篇关于使用存储过程将数据插入表中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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