Hi,
I have an ultracombo control that gets filled by a dataset. If I do not choose anything and press the save button the value of the combo equals 'default' and the SQL stored procedure gives an error as 'default' is passed instead of null.
How can I send a null value if nothing is selected?
Thanks.
Okay, but at least we have established that it's not "default". :)
I think what you need to do is set the DataSourceNullValue property on the Binding to DBNull.Value.
SQL Profiler shows all the commands that are executed against SQL Server. In my example I am executing a stored procedure, passing the parameters of that Stored Procedure.
I examined the value property in debug mode and its null. But its propably NOT the System.DBNull.value required from the database.
Regards,
Nicolas
I'm not that familiar with SQL Profiler, but I suspect that is an artifact of how the exec string is being built, not the value of the Combo. Have you tried examining the Value property of the combo to see what's actually being returned? I notice that 'default' here is not in quotes, so it looks like it's using this to indicate that the value has not been changed.
I am using SQL Server.
One of the parameteres in my form is an ultraCombo and I pass the following parameter when updating the record.
comm.Parameters.Add("@Surgeon", SqlDbType.BigInt).Value = cmbSurgeons.Value;
However this gives an error saying that stored procedure 'xxxx' expects parameter "@Surgeon" which was not supplied.
In SQL Profiler these are the values that are passed
exec tblSurgicalProcedure_INSERT @Patient = 1715, @PerformedDate = 'Dec 21 2007 5:20:41:000PM', @Surgeon = default, @Remarks = NULL
As you can see the @Surgeon got a value of 'default' instead of null.
I don't understand. What do you mean by "default"? Is this a string? If so, where is it coming from? The Combo doesn't default to some arbitrary string as it's value so this must be coming from something in your code or your data.