Outparameter Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm testing OleDbCommand for calling a store procedure in a Sybase DB
I'm using an output parameter but always I get DBNull

here is my code:

Dim conn As New OleDbConnection(connStr)
Dim cmd As New OleDbCommand("HO_ProcTest", conn)
cmd.CommandType = CommandType.StoredProcedure
Dim workParam As OleDbParameter

cmd.Parameters.Add("@firstDate", OleDbType.DBTimeStamp)
cmd.Parameters("@firstDate").Value = Date.Now

workParam = cmd.Parameters.Add("@Out", OleDbType.Integer)
workParam.Direction = ParameterDirection.Output

Try
conn.Open()
cmd.ExecuteNonQuery()
Dim str = cmd.Parameters("@Out").Value()
Catch ex As Exception

Finally
conn.Close()
End Try

obviously the store procedure is fine I test it,

From my point of view this is a bug.

Any Solution??
Thanks
 
Try closing the connection before checking the output parameter.

conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
Dim str = cmd.Parameters("@Out").Value()
 
I already try that too, I not sure if is a driver problem or what, but all I
get is DBNull,

?
 
Back
Top