+2007-05-02 Igor Zelmanovich <igorz@mainsoft.com>
+
+ * SqlDataSourceView.cs:
+ make CancelSelectOnNullParameter property works.
+
2007-05-01 Marek Habersack <mhabersack@novell.com>
* BaseValidator.cs: do not use User-Agent directly, we must take
if (dataView == null) {
SqlDataSourceSelectingEventArgs selectingArgs = new SqlDataSourceSelectingEventArgs (command, arguments);
OnSelecting (selectingArgs);
- if (selectingArgs.Cancel) {
+ if (selectingArgs.Cancel || !PrepareNullParameters (command, CancelSelectOnNullParameter)) {
return null;
}
try {
else {
SqlDataSourceSelectingEventArgs selectingArgs = new SqlDataSourceSelectingEventArgs (command, arguments);
OnSelecting (selectingArgs);
- if (selectingArgs.Cancel) {
+ if (selectingArgs.Cancel || !PrepareNullParameters (command, CancelSelectOnNullParameter)) {
return null;
}
}
}
+ static bool PrepareNullParameters (DbCommand command, bool cancelIfHas)
+ {
+ for (int i = 0; i < command.Parameters.Count; i++) {
+ DbParameter param = command.Parameters [i];
+ if (param.Value == null && ((param.Direction & ParameterDirection.Input) != 0)) {
+ if (cancelIfHas)
+ return false;
+ else
+ param.Value = DBNull.Value;
+ }
+ }
+ return true;
+ }
+
public int Update (IDictionary keys, IDictionary values, IDictionary oldValues)
{
return ExecuteUpdate (keys, values, oldValues);
{
DbParameter dbp = factory.CreateParameter ();
dbp.ParameterName = ParameterPrefix + name;
- if (value == null)
- dbp.Value = DBNull.Value;
- else
- dbp.Value = value;
+ dbp.Value = value;
dbp.Direction = dir;
if (size != -1)
dbp.Size = size;