Sql 参数似乎没有添加字符串的单引号(提交事务问题)
我不确定如何准确表达问题标题。
我有这段代码,用于为执行插入的存储过程设置 sql 参数。
Dim sproc As StoredProcedure = New StoredProcedure("UsersInsert2", DataAccessConfiguration)
sproc.AddInput("@ID", SqlDbType.NVarChar, 10, entity.UserId)
sproc.AddInput("@PCode", SqlDbType.SmallInt, entity.PriviledgeCode)
sproc.AddInput("@Pwd", SqlDbType.NVarChar, 10, entity.Password.ToString())
sproc.AddInput("@Lang", SqlDbType.NVarChar, 1, entity.DefaultLanguage)
sproc.AddInput("@Name", SqlDbType.NVarChar, 40, entity.UserName)
sproc.AddInput("@Notice", SqlDbType.TinyInt, entity.SaveNotice)
sproc.AddInput("@CreatedBy", SqlDbType.VarChar, 50,CurrentUserCredentials.UserName)
我已经在 SSMS 中测试了存储过程并且它有效。 问题是当我尝试从应用程序调用它时。它失败了。 @@行计数 = -1。我尝试从数据库返回错误代码...没有骰子。不断返回-1,
将要执行的内容看起来像这样,
sproc = {EXEC UsersInsert2 @ID=ruxtest7, @PCode=0, @Pwd=1234, @Lang=E, @Name=ruxpint, @Notice=1, @CreatedBy=ruxpint}
知道问题是什么吗?我已经多次重复使用此代码。唯一的区别是我使用的是 NVarChar,它是 vb.net。
谢谢。
TR
I wasn't sure exactly how to phrase the question Title.
I have this block of code that sets up my sql parameters for a stored proc that does an insert.
Dim sproc As StoredProcedure = New StoredProcedure("UsersInsert2", DataAccessConfiguration)
sproc.AddInput("@ID", SqlDbType.NVarChar, 10, entity.UserId)
sproc.AddInput("@PCode", SqlDbType.SmallInt, entity.PriviledgeCode)
sproc.AddInput("@Pwd", SqlDbType.NVarChar, 10, entity.Password.ToString())
sproc.AddInput("@Lang", SqlDbType.NVarChar, 1, entity.DefaultLanguage)
sproc.AddInput("@Name", SqlDbType.NVarChar, 40, entity.UserName)
sproc.AddInput("@Notice", SqlDbType.TinyInt, entity.SaveNotice)
sproc.AddInput("@CreatedBy", SqlDbType.VarChar, 50,CurrentUserCredentials.UserName)
I've tested the stored proc in SSMS and it works.
The problem is when I try to call it from the application. it fails. the @@rowcount = -1. I've tried returning an error code from the db... no dice. keeps coming back as -1
what is going to get executed looks like this
sproc = {EXEC UsersInsert2 @ID=ruxtest7, @PCode=0, @Pwd=1234, @Lang=E, @Name=ruxpint, @Notice=1, @CreatedBy=ruxpint}
any idea what the issue is? I've re-used this code several times. only difference being I'm using NVarChar and it's vb.net.
thanks.
TR
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明我的存储过程调用没问题。在我执行事务的基类中,我忘记提交它。噢! (这可能会对将来的某人有所帮助)
So turns out my stored proc call was fine. in my base class where I perform the transaction, I forgot to commit it. D'oh! (This may help someone in the future)