C#存储过程错误db参数是预期的 [英] C# stored procedure error db parameter expected

查看:76
本文介绍了C#存储过程错误db参数是预期的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。



我有一个存储过程,它将数据从Web表单插入到我的数据库中的表中。在执行过程中弹出一个错误,例如过程或函数'getpopteam'需要参数'@tname',它没有提供。但是当我在db中输入我的表时,所有在web表单中不相关的值都存在于db中,我再次执行它提到错误再次弹出,所有值都成功插入数据库。不知道是什么问题?请帮忙?

Hi.

I have a stored procedure which inserts data from a web form to a table in my database.During the execution an error popped up such as"Procedure or function 'getpopteam' expects parameter '@tname', which was not supplied".But when i entered into the my table in the db all the values insereted in the web form is present in the db,i executed it again and above mentioned error popped up again and all the values are successfully inserted into the database .Don't know what the problem is ?? please help?

推荐答案

我看到当参数值为NULL而不是DBNull.Value时。



尝试使用null coalescing运算符作为参数值: parm.Value = value ?? DBNull.Value



http://msdn.microsoft.com/en-us/library/ms173224.aspx [ ^ ]
I see that when a parameter value is NULL rather than DBNull.Value.

Try using the null coalescing operator for your parameter values: parm.Value = value ?? DBNull.Value

http://msdn.microsoft.com/en-us/library/ms173224.aspx[^]


这篇关于C#存储过程错误db参数是预期的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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