Monday, March 19, 2012

Keyword not supported: ,server.

Hello there.

I'm developing an eCommerce solutions based on the ASP.NET 2.0 Commerce Starter Kit, architechture. It uses the Provider Pattern. In my web-application, i use the CatalogProvider, to retrieve data from a SQL Server 2005 database. I call the methods through a handler class, whoch excists inside the WebApp. I also use a ShoppingCartProvider, OrdersProvider, ShippingProvider etc. in the same way.

In my Web.Config file, i have all the provers listed, and on each provider, the name of the connectionString to use are given.

My connection string looks like this:

"connString" connectionString="Server=xxxx;Database=xxxx;Trusted_Connection=True;" providerName="System.Data.SqlClient" />

The problem is, that suddently, when browsing the website, that connects to the database through the providers, i get this error:

Keyword not supported: ',server'.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.ArgumentException: Keyword not supported: ',server'.

Source Error:

Line 31: public static IDataReader GetProductsByCategory(int categoryID)Line 32: {Line 33: return Commerce.Providers.CatalogProvider.Instance.GetProductsByCategory(categoryID);Line 34: }Line 35:


Source File:d:\Development\ASPNET\SeoShop\App_Code\Handlers\CatalogManager.cs Line:33

Stack Trace:

If i then go back to my web.config file, and removes the providerName section, of the connectionString, the website works again, for a short period. When the error return, i undo the deletion of the providerName, and it will work again... For a short time...

I've also tried to use another connectionsString, like this:
Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI

But then the keyword which is not supported is: ', data source'

Does anyone know what the issue might be?

Thanks in advance...

I see the keyword is ",server". Where's the comma coming from? That's your problem.|||

I don't know where it is coming from. It seems very wierd, that it is there. But the fact, that it only happens occassionally, is the wierdest thing, though.

I might review my providers data-access layer, to see if the comma occurs, but i doubt it.

|||
Perhaps changing your connection to something like this might help:
connectionString="Server=xxxx;Database=xxxx;Trusted_Connection=True;providerName=System.Data.SqlClient"
 
|||

ndinakar >>

That returns the following error:

Keyword not supported: 'providername'.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.ArgumentException: Keyword not supported: 'providername'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[ArgumentException: Keyword not supported: 'providername'.] System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) +1406530 System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) +102 System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) +52 System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) +24 System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) +125 System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value) +56 System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) +4 System.Data.SqlClient.SqlConnection..ctor(String connectionString) +21 System.Web.DataAccess.SqlConnectionHolder..ctor(String connectionString) +40

|||

You could use:

"Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;"
- or -
"Server=Aron1;Database=pubs;Trusted_Connection=True;"
(both connection strings produces the same result)

|||

ndinakar wrote the following post at 06-28-2006 5:51 PM:

You could use:

"Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;"
- or -
"Server=Aron1;Database=pubs;Trusted_Connection=True;"
(both connection strings produces the same result)

Doesn't make a difference, regarding my problem!

|||can you post your updated code ?|||

I've been digging deeper into this problem now for some time.

The problem seems to be caused by caching the connection-string and providername. Take a look at this error message form ASP.NET:


System.Data.SqlClient,System.Data.SqlClient,System.Data.SqlClient

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.Exception: System.Data.SqlClient,System.Data.SqlClient,System.Data.SqlClient

Source Error:

Line 24: catch (ArgumentException)Line 25: {Line 26: throw new Exception(providerName);Line 27: }Line 28: DbConnection myConn = fact.CreateConnection();

As I see it, it adds the providername and delimits the records with a , (comma).

The code looks like this:

1using System;2using System.Reflection;3using System.Collections.Specialized;4using System.Configuration.Provider;5using System.Data;6using System.Web.Caching;7using System.Web;8using System.Web.Configuration;9using System.Configuration;1011namespace Commerce.Providers12{1314public abstract class CatalogProvider : System.Configuration.Provider.ProviderBase15 {1617static CatalogProvider _instance;1819static object padLock;20public static CatalogProvider Instance21 {2223get24 {25 CatalogProvider tempInstance;26if (_instance ==null)27 padLock =new object();28lock (padLock)29 {30 tempInstance = LoadProvider();31 _instance = tempInstance;32 }3334return _instance;35 }36 }3738public static CatalogProvider LoadProvider()39 {40// Get the names of the providers41 // Use the cache because the reflection used later is expensive42 Cache cache = System.Web.HttpRuntime.Cache;43string cacheKey =null;4445 CatalogProvider _instanceLoader;46 CatalogProviderConfiguration config = CatalogProviderConfiguration.GetConfig();47 cacheKey ="CatalogProvider::" + config.DefaultProvider;4849 cache.Remove(cacheKey);50object oProvider = cache.Get(cacheKey);51if (oProvider !=null)52 {53 _instanceLoader = (CatalogProvider)oProvider;54 }55else56 {5758try59 {6061// Read the configuration specific information for this provider62 Provider CatalogProvider = (Provider)config.Providers[config.DefaultProvider];6364// The assembly should be in \bin or GAC65 Type type = Type.GetType(CatalogProvider.Type);66 _instanceLoader = (CatalogProvider)Activator.CreateInstance(type);6768// Initialize the provider with the attributes.69string cStringName = CatalogProvider.Attributes["connectionStringName"];70string cString = System.Configuration.ConfigurationManager.ConnectionStrings[cStringName].ConnectionString;71string providerName = System.Configuration.ConfigurationManager.ConnectionStrings[cStringName].ProviderName;72 CatalogProvider.Attributes.Add("connectionString", cString);73 CatalogProvider.Attributes.Add("providerName", providerName);74 _instanceLoader.Initialize(CatalogProvider.Name, CatalogProvider.Attributes);7576//pop it into the cache to keep out site from running into the ground :)77 cache.Insert(cacheKey, _instanceLoader);7879 }80catch (Exception e)81 {82throw new Exception("Unable to load provider", e);83 }84 }85return _instanceLoader;86 }878889#region Products90public abstract IDataReader ProductsSearch(string query);91public abstract IDataReader GetProducts();92public abstract int AddCategory(int parentID,string categoryName,string metaKeywords,string metaDescription,string metaRobotsTag,string pageTitle);93public abstract IDataReader GetCategories();94public abstract IDataReader GetCompleteCategoriesList();95public abstract IDataReader GetCategoryByID(int categoryId);96public abstract IDataReader GetCategoryByParentID(int parentId);97public abstract IDataReader GetProductsByCategory(int categoryID);98public abstract IDataReader GetProductsByWhereClause(string whereClause);99public abstract IDataReader GetProduct(int productID);100101public abstract IDataReader GetTagList();102103public abstract void FillProductDataSet(int productID, DataSet ds);104public abstract bool ProductIsActive(int productID);105106public abstract void ProductsAdjustInventory(int productID,int newAmount,string comment);107public abstract IDataReader ProductsInventoryHistory(int productID);108public abstract void ProductInactivate(int productID);109public abstract void ProductDeletePermanent(int productID);110111public abstract int ProductInsert(string metaKeywords,string metaDescription,string metaRobotsTag,int categoryID,string modelNumber,string modelName,double unitCost,string description,int amountOnHand,string sku,double weight,bool isActive,int discountPercent,string pageTitle);112public abstract int InsertProductImage(int productID,string thumbPath,string mediumPath,string mainPath);113public abstract void ProductUpdate(int productID,string metaKeywords,string metaDescription,string metaRobotsTag,int categoryID,string modelNumber,string modelName,double unitCost,string description,int amountOnHand,string sku,double weight,bool isActive,int discountPercent,string pageTitle,string thumbPath,string mediumPath,string mainPath);114115#endregion116 }117}118

All the settings are stored in the web.config.|||Found a solution:http://forums.asp.net/thread/1418919.aspx

No comments:

Post a Comment