Browse Source

2007-04-30 Marek Habersack <[email protected]>

	* ConnectionStringsExpressionBuilder.cs: support expressions with
	suffixes .ProviderName and .ConnectionString (case-insensitie) and
	generate a call to GetConnectionStringProviderName in the former
	case. Fixes bug #81490

2007-04-30  Marek Habersack  <[email protected]>

	* SqlDataSource.cs: do not catch the exception if ProviderName is
	not null or empty (as per docs and what MS.NET does).

2007-04-30  Marek Habersack  <[email protected]>

	* DbProviderFactories.cs: throw the same exception MS.NET does.

svn path=/trunk/mcs/; revision=76486
Marek Habersack 18 years ago
parent
commit
d105ea0838

+ 4 - 0
mcs/class/System.Data/System.Data.Common/ChangeLog

@@ -1,3 +1,7 @@
+2007-04-30  Marek Habersack  <[email protected]>
+
+	* DbProviderFactories.cs: throw the same exception MS.NET does.
+
 2007-03-03  Gert Driesen  <[email protected]>
 
 	* DbProviderFactoriesConfigurationHandler.cs: Added support for

+ 2 - 2
mcs/class/System.Data/System.Data.Common/DbProviderFactories.cs

@@ -66,7 +66,7 @@ namespace System.Data.Common {
 				}
 			}
 
-			throw new ConfigurationException("DataProvider is missing!");
+			throw new ConfigurationErrorsException("Failed to find or load the registered .Net Framework Data Provider.");
 		}
 
 		public static DbProviderFactory GetFactory (string providerInvariantName)
@@ -77,7 +77,7 @@ namespace System.Data.Common {
 				if (row != null)
 					return GetFactory (row);
 			}
-			throw new ConfigurationException ("DataProvider is not found!");
+			throw new ConfigurationErrorsException ("Failed to find or load the registered .Net Framework Data Provider.");
 		}
 
 		public static DataTable GetFactoryClasses ()

+ 5 - 0
mcs/class/System.Web/System.Web.Compilation/ChangeLog

@@ -1,5 +1,10 @@
 2007-04-30  Marek Habersack  <[email protected]>
 
+	* ConnectionStringsExpressionBuilder.cs: support expressions with
+	suffixes .ProviderName and .ConnectionString (case-insensitie) and
+	generate a call to GetConnectionStringProviderName in the former
+	case. Fixes bug #81490
+
 	* AppCodeCompiler.cs: support for cases when there exists a custom
 	profile class but there is no App_Code directory or it's
 	empty. Fixes bug #81489. 

+ 19 - 4
mcs/class/System.Web/System.Web.Compilation/ConnectionStringsExpressionBuilder.cs

@@ -54,7 +54,7 @@ namespace System.Web.Compilation {
 			Pair connString = parsedData as Pair;
 			return new CodeMethodInvokeExpression (
 				new CodeTypeReferenceExpression (typeof (ConnectionStringsExpressionBuilder)),
-				"GetConnectionString",
+				(bool)connString.Second ? "GetConnectionStringProviderName" : "GetConnectionString",
 				new CodeExpression [] {new CodePrimitiveExpression (connString.First)}
 			);
 		}
@@ -63,7 +63,7 @@ namespace System.Web.Compilation {
 		{
 			ConnectionStringSettings conn = WebConfigurationManager.ConnectionStrings [connectionStringName];
 			if (conn == null)
-				return "";
+				return String.Empty;
 			else
 				return conn.ConnectionString;
 		}
@@ -72,14 +72,29 @@ namespace System.Web.Compilation {
 		{
 			ConnectionStringSettings conn = WebConfigurationManager.ConnectionStrings [connectionStringName];
 			if (conn == null)
-				return "";
+				return String.Empty;
 			else
 				return conn.ProviderName;
 		}
 
 		public override	object ParseExpression (string expression, Type propertyType, ExpressionBuilderContext context)
 		{
-			return new Pair (expression, GetConnectionString (expression));
+			bool wantsProviderName = false;
+			string connStringName = String.Empty;
+
+			if (!String.IsNullOrEmpty (expression)) {
+				int subidx = expression.Length;
+				
+				if (expression.EndsWith (".providername", StringComparison.InvariantCultureIgnoreCase)) {
+					wantsProviderName = true;
+					subidx -= 13;
+				} else if (expression.EndsWith (".connectionstring", StringComparison.InvariantCultureIgnoreCase))
+					subidx -= 17;
+
+				connStringName = expression.Substring (0, subidx);
+			}
+			
+			return new Pair (connStringName, wantsProviderName);
 		}
 
 		public override bool SupportsEvaluate {

+ 5 - 0
mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog

@@ -1,3 +1,8 @@
+2007-04-30  Marek Habersack  <[email protected]>
+
+	* SqlDataSource.cs: do not catch the exception if ProviderName is
+	not null or empty (as per docs and what MS.NET does).
+
 2007-04-19 Igor Zelmanovich <[email protected]>
 
 	* ChangePassword.cs:

+ 3 - 7
mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSource.cs

@@ -91,13 +91,9 @@ namespace System.Web.UI.WebControls {
 		{
 			DbProviderFactory f = null;
 
-			if (ProviderName != null && ProviderName != "") {
-				try {
-					f = DbProviderFactories.GetFactory(ProviderName);
-				}
-				catch { /* nada */ }
-				if (f != null)
-					return f;
+			if (!String.IsNullOrEmpty (ProviderName)) {
+				f = DbProviderFactories.GetFactory(ProviderName);
+				return f;
 			}
 
 			return SqlClientFactory.Instance;