I'm connected to Sybase ASA version 8.02

Trying to execute the following command:

myCommand.Connection = OleDbConnection1
myCommand.Transaction = myTrans
cmd = "INSERT INTO mvr_viol
(servicekey,source,info,viol,conv,description,code,points,acd,avd,disposition)"
cmd = cmd & " VALUES (?,1,?,?,?,?,?,?,?,?,?)"
myCommand.CommandText = cmd

I create the 10 parameters, fill them with data, and the
ExecuteNonQuery works fine.

However, is some cases I need one of the columns set to "NULL"
so in that case there is this snippet:

myCommand.Parameters(3).IsNullable = True
myCommand.Parameters(3).Value = DBNull.Value

However, this time the ExecuteNonQuery fails with the message:
"Count field incorrect: Not enough values for host variables"

There are still 10 parameters, yet it fails. Can this be made to work?

Passing a null parameter by Rich

Rich
Wed Sep 03 09:58:02 CDT 2003

Instead of DBNull.Value try
Imports System.Data.SqlTypes

myCommand.Parameters(3).Value = SQLString.Null
OR
myCommand.Parameters(3).Value = SqlInt32.Null

I hope this helps.
I'm trying to do it without a parameter object.


>-----Original Message-----
>I'm connected to Sybase ASA version 8.02
>
>Trying to execute the following command:
>
> myCommand.Connection = OleDbConnection1
> myCommand.Transaction = myTrans
> cmd = "INSERT INTO mvr_viol
>
(servicekey,source,info,viol,conv,description,code,points,
acd,avd,disposition)"
> cmd = cmd & " VALUES (?,1,?,?,?,?,?,?,?,?,?)"
> myCommand.CommandText = cmd
>
> I create the 10 parameters, fill them with data, and the
>ExecuteNonQuery works fine.
>
> However, is some cases I need one of the columns set
to "NULL"
> so in that case there is this snippet:
>
> myCommand.Parameters(3).IsNullable = True
> myCommand.Parameters(3).Value = DBNull.Value
>
>However, this time the ExecuteNonQuery fails with the
message:
> "Count field incorrect: Not enough values for host
variables"
>
>There are still 10 parameters, yet it fails. Can this be
made to work?
>.
>