我正在使用dapper将数据保存到数据库。使用存储过程,我无法从SQL获取参数返回值(@ID)。在数据库中,我正在使用数据类型为Bigint Out的参数。请告诉我如何使用dapper存储过程获取参数输出值。
这是我的代码:
Public Function SavedataRet(e As Employe) As Boolean
Using cn As SqlConnection = New SqlConnection(clas._ActiveCn)
cn.Open()
Dim dParams As New DynamicParameters, j As Integer
With dParams
.Add("@ID", e.Id, SqlDbType.BigInt, direction:=ParameterDirection.InputOutput)
.Add("Name", e.Name, SqlDbType.VarChar, direction:=ParameterDirection.Input)
.Add("@Phone", e.Phone, SqlDbType.VarChar, direction:=ParameterDirection.Input)
.Add("@Address", e.Address, SqlDbType.VarChar, direction:=ParameterDirection.Input)
End With
Using Trx As IDbTransaction = cn.BeginTransaction
cn.Execute("sp_simpan", dParams, Trx, commandType:=CommandType.StoredProcedure)
Trx.Commit()
MessageBox.Show(e.Id)' here iwant to get parameter return----
End Using
End Using
Return True
End Function