passing Oracle Nulls into a parameter

  • Thread starter Thread starter Craig G
  • Start date Start date
C

Craig G

how do you pass a null into an oracle parameter?

i am doing the following which works fine when there is data to be passed in
but when the string is blank it wont accept "" or even as a system.dbnull

'Parameter for Address1

Dim parAddress1 As OracleClient.OracleParameter

parAddress1 = cmdInsert.Parameters.Add("strAddress1",
OracleClient.OracleType.VarChar)

parAddress1.Direction = ParameterDirection.Input



parAddress1.Value = Strings.UCase(strAddress1)



if have tried doing something like this

If strAddress1 = "" Then

parAddress1.Value = myDBNull (which is simply a variable as type
system.dbnull)

end if

but still no joy



Cheers,
Craig
 
Craig G said:
how do you pass a null into an oracle parameter?

i am doing the following which works fine when there is data to be passed
in
but when the string is blank it wont accept "" or even as a system.dbnull

'Parameter for Address1

Dim parAddress1 As OracleClient.OracleParameter

parAddress1 = cmdInsert.Parameters.Add("strAddress1",
OracleClient.OracleType.VarChar)

parAddress1.Direction = ParameterDirection.Input



parAddress1.Value = Strings.UCase(strAddress1)



if have tried doing something like this

If strAddress1 = "" Then

parAddress1.Value = myDBNull (which is simply a variable as type
system.dbnull)

end if

but still no joy
Either

parAddress1.Value = ""
or
parAddress1.Value = DbNull.Value


will pass a NULL to Oracle.
As Oracle refuses to distinguish between a null and an empty string.

David
 
if found that it didnt like parAddress.Value = ""

came back with an error saying the size was not set for that parameter
 
Back
Top