Outparameter Problem


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
 
Ad

Advertisements

J

Jim Hughes

Try closing the connection before checking the output parameter.

conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
Dim str = cmd.Parameters("@Out").Value()
 
Ad

Advertisements

G

Guest

I already try that too, I not sure if is a driver problem or what, but all I
get is DBNull,

?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top