J
Jim Heavey
Hello, I am trying to understand why one set of instructions work for
creating a SQLParameter and another set does not.
This set works just fine...
Dim parm As New SqlParameter()
parm.DbType = DbType.Int16
'parm.Size = 4
parm.Direction = ParameterDirection.ReturnValue
cmd.Parameters.Add(parm)
This one does not
cmd.Parameters.Add(New SqlParameter("@RETURN_VALUE", DbType.Int16, 2,
ParameterDirection.ReturnValue))
When I run with the second version It gives me an error indicating that
I have not supplied any parms.
I am sure I have seen another version of this command which looks like
the following and allows you to set the value as well...
cmd.Parameters.Add(New SqlParameter("@SomeParm", DbType.Int16, 2,
ParameterDirection.ReturnValue).Value="My Value")
I presume that I should probably use the SQLDbType and not the DbType,
but it does not seem to care (at least on the 1st version).
Can you set me straight as to why the first version works and the second
does not.
Can I set the Name, value, type and direction with just a single
instruction?
Thanks in advance for your assistance!!!!!!!!
creating a SQLParameter and another set does not.
This set works just fine...
Dim parm As New SqlParameter()
parm.DbType = DbType.Int16
'parm.Size = 4
parm.Direction = ParameterDirection.ReturnValue
cmd.Parameters.Add(parm)
This one does not
cmd.Parameters.Add(New SqlParameter("@RETURN_VALUE", DbType.Int16, 2,
ParameterDirection.ReturnValue))
When I run with the second version It gives me an error indicating that
I have not supplied any parms.
I am sure I have seen another version of this command which looks like
the following and allows you to set the value as well...
cmd.Parameters.Add(New SqlParameter("@SomeParm", DbType.Int16, 2,
ParameterDirection.ReturnValue).Value="My Value")
I presume that I should probably use the SQLDbType and not the DbType,
but it does not seem to care (at least on the 1st version).
Can you set me straight as to why the first version works and the second
does not.
Can I set the Name, value, type and direction with just a single
instruction?
Thanks in advance for your assistance!!!!!!!!