C
C Newby
I'm sure the answer to this is simple...I hope anyway...
Given the following (C#):
sqlCommand command = new sqlCommand();
command.Connection = someOpenConnectionObject;
command.CommandText = "INSERT INTO myTable ( myTextField ) VALUES (
@myTextField )";
SqlParameter parameter = new SqlParameter();
parameter.ParameterName = "@myTextField";
parameter.Size = 8000;
parameter.DbType = System.Data.DbType.String;
parameter.Value = ARatherBigString;
parameter.IsNullable = true;
command.paramaters.add( parameter );
command.ExecuteNonQuery();
If ARatherBigString contains text, all is well and a new record is inserted
into myTable. However, if ARatherBigString is null, i get a "Prepared
statement ... expects parameter @myTextField " exception from SQL Server.
But if ARatherBigString is null, i *would* like to insert a record with a
null value.
So my question is, what is the best way to do this?
TIA//
Given the following (C#):
sqlCommand command = new sqlCommand();
command.Connection = someOpenConnectionObject;
command.CommandText = "INSERT INTO myTable ( myTextField ) VALUES (
@myTextField )";
SqlParameter parameter = new SqlParameter();
parameter.ParameterName = "@myTextField";
parameter.Size = 8000;
parameter.DbType = System.Data.DbType.String;
parameter.Value = ARatherBigString;
parameter.IsNullable = true;
command.paramaters.add( parameter );
command.ExecuteNonQuery();
If ARatherBigString contains text, all is well and a new record is inserted
into myTable. However, if ARatherBigString is null, i get a "Prepared
statement ... expects parameter @myTextField " exception from SQL Server.
But if ARatherBigString is null, i *would* like to insert a record with a
null value.
So my question is, what is the best way to do this?
TIA//