在vb.net前端上调用Strore过程 [英] Calling a strore procedure on vb.net front end
本文介绍了在vb.net前端上调用Strore过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友们,
如果表中有注册Nubmer,我已经创建了一个存储过程来获取表中的更新值.我会编写以下代码
Hi friends,
I have created a store procedure to get update value in table if registration Nubmer is available in table. I''d code the following
CREATE PROC proc_UpdateOldBalance(@RegistrationNumber char(8), @BalanceAmount bigint)
as
Declare @RowCount int
SELECT @RowCount = COUNT(*) FROM OldBalance Where RegistrationNumber=@RegistrationNumber
if (@rowCount<1)
BEGIN
PRINT 'You can not Update data. RegistrationNumber not available'
ROLLBACK TRANSACTION
END
else
update oldBalance set BalanceAmount = @BalanceAmount where RegistrationNumber=@RegistrationNumber
return
它在后端运行正常,但是当我在前端使用它时会出错.
代码如下
it is running fine on back-end But when I''m using this on front end it gives error.
code is as follow
try
Dim mycom As SqlCommand = New SqlCommand("proc_UpdateOldBalance", ConnObj, transction)
mycom.CommandType = CommandType.StoredProcedure
mycom.Parameters.AddWithValue("@RegistrationNumber", txtRegistrationNo.Text)
mycom.Parameters.AddWithValue("@BalanceAmount", txtBalanceRemain.Text)
mycom.ExecuteNonQuery()
transction.Commit()
Catch sqlError As SqlException
transction.Rollback()
MessageBox.Show("Unable to deposit Fees" + System.Environment.NewLine + "Please contact Your Software Provider", "Payment Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
MessageBox.Show(Convert.ToString(sqlError))
Exit Sub
End Try
调用ExecuteNonQuery方法时会给出错误.请尽快帮助我.
谢谢
it gives error when ExecuteNonQuery method calls. Kindly help me soon.
thanks
推荐答案
我认为有交易错误.请从前端删除事务,然后尝试.
I think there is transaction Error. Please remove transaction from front end and try it.
我忘了写
transction = ConnObj.BeginTransaction
I''ve forgot to write
transction = ConnObj.BeginTransaction
这篇关于在vb.net前端上调用Strore过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文