我不确定如何标题问题。
我有这个代码块,用于为执行插入的存储过程设置我的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中测试了存储过程,但它确实有效。 问题是当我尝试从应用程序中调用它时。它失败。 @@ rowcount = -1。我已经尝试从db中返回错误代码...没有骰子。不断回来-1
将要执行的内容如下所示
sproc = {EXEC UsersInsert2 @ID=ruxtest7, @PCode=0, @Pwd=1234, @Lang=E, @Name=ruxpint, @Notice=1, @CreatedBy=ruxpint}
知道问题是什么吗?我已经多次重复使用这段代码了。唯一的区别是我正在使用NVarChar,而且它是vb.net。
感谢。
TR
答案 0 :(得分:0)
结果我的存储过程调用很好。在我执行事务的基类中,我忘了提交它。 D'哦! (这可能会帮助将来的某个人)
Try
x = command.ExecuteNonQuery()
transaction.Commit() <- I was missing this line!!!
Catch ex As Exception
transaction.Rollback()
Finally
If conn.State And ConnectionState.Closed = 0 Then
conn.Close()
End If
End Try