Author: igorz
Date: 2007-05-02 05:46:07 -0400 (Wed, 02 May 2007)
New Revision: 76559
Modified:
trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
trunk/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceView.cs
Log:
2007-05-02 Igor Zelmanovich <[EMAIL PROTECTED]>
* SqlDataSourceView.cs:
make CancelSelectOnNullParameter property works.
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
2007-05-02 09:45:24 UTC (rev 76558)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
2007-05-02 09:46:07 UTC (rev 76559)
@@ -1,3 +1,8 @@
+2007-05-02 Igor Zelmanovich <[EMAIL PROTECTED]>
+
+ * SqlDataSourceView.cs:
+ make CancelSelectOnNullParameter property works.
+
2007-05-01 Marek Habersack <[EMAIL PROTECTED]>
* BaseValidator.cs: do not use User-Agent directly, we must take
Modified:
trunk/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceView.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceView.cs
2007-05-02 09:45:24 UTC (rev 76558)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceView.cs
2007-05-02 09:46:07 UTC (rev 76559)
@@ -229,7 +229,7 @@
if (dataView == null) {
SqlDataSourceSelectingEventArgs
selectingArgs = new SqlDataSourceSelectingEventArgs (command, arguments);
OnSelecting (selectingArgs);
- if (selectingArgs.Cancel) {
+ if (selectingArgs.Cancel ||
!PrepareNullParameters (command, CancelSelectOnNullParameter)) {
return null;
}
try {
@@ -279,7 +279,7 @@
else {
SqlDataSourceSelectingEventArgs selectingArgs =
new SqlDataSourceSelectingEventArgs (command, arguments);
OnSelecting (selectingArgs);
- if (selectingArgs.Cancel) {
+ if (selectingArgs.Cancel ||
!PrepareNullParameters (command, CancelSelectOnNullParameter)) {
return null;
}
@@ -304,6 +304,20 @@
}
}
+ 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);
@@ -450,10 +464,7 @@
{
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;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches