Webconfig file not formed correclty - c#

On my live box I am getting an error that the connection string is malformerd but when i try it on my dev box it is fine.
<add name="aperturenetEntities" connectionString="metadata=res://*/ApertureModel.csdl|res://*/ApertureModel.ssdl|res://*/ApertureModel.msl;provider=System.Data.SqlClient;provider connection string="data source=APR-AZ-DB01;initial catalog=aperturenet;user id=aperturenet;password=dw13£sowwoq;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="aperturenetSql" connectionString="Data Source=APR-AZ-DB01;database=aperturenet;User ID=username;Password=password" providerName="System.Data.SqlClient" />
They are both .net 4.5 boxes with no difference in sql version of the driver but yet i get malformed elements when running the application any idea?.

<add name="aperturenetEntities" connectionString="metadata=res://*/ApertureModel.csdl|res://*/ApertureModel.ssdl|res://*/ApertureModel.msl;provider=System.Data.SqlClient;provider connection string="data source=APR-AZ-DB01;initial catalog=aperturenet;user id=aperturenet;password=dw13£sowwoq;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
try this,
i have changed Application Name to App in your connection string.

Related

Keyword not supported 'data source' error

my connection string cannot login to my database.This is my connectionString
<add name="ProductEntities" connectionString="Data Source=**.**.***.**\MSSQLSERVER2017;Database=product1_;User Id=product;Password=*****;" providerName="System.Data.EntityClient" />
And these connectionStrings are that i tried in web.config
connectionString="Data Source=**.***.**.**\MSSQLSERVER2017;Network Library=DBMSSOCN;Initial Catalog=product1_;User ID=product;Password=*****;"
connectionString="data source=**.***.**.**\MSSQLSERVER2017;initial catalog=product1_;user id=product;password=*****;integrated security=True;MultipleActiveResultSets=True"
providerName="System.Data.EntityClient" />
and the other error is database cannot open.How can i fix this ?

How to fix this Keyword not supported "provider" for C#?

First, I had similar problem Keyword not supported for "metadata". So, I wrote data source instead of metadata. After that, I tried to create Controller for ASP.NET MVC and that show me Keyword not supported for "provider". I read the some case for SQL SERVER connection, but I didn't found for Oracle connection.
Here is my connectionStrings in web.config file.
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-MVC-20170801212521;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-MVC-20170801212521.mdf" providerName="System.Data.SqlClient" />
<add name="EntitiesLL" connectionString="Data Source=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=Oracle.ManagedDataAccess.Client;data source=****:1111/xe;password=******;user id=******;" providerName="System.Data.SqlClient" />
</connectionStrings>
Thank you.
The problem is this
providerName="System.Data.SqlClient"
Something tells me it should be OracleClient.
According to official documentation this should read:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-MVC-20170801212521;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-MVC-20170801212521.mdf" providerName="System.Data.SqlClient" />
<add name="EntitiesLL" connectionString="Data Source=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;data source=****:1111/xe;password=******;user id=******;" providerName="Oracle.ManagedDataAccess.Client" />
</connectionStrings>

how to put a webhostdatabase connection string in a winform application?

i have myself tried a lot but i couldn't find out what is the problem of my below connection string. i have put both my webhost connection string and winform connection string help please?
<connectionStrings> <add name="ReGdbEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;
provider=System.Data.SqlClient;
provider connection string="data source=.\SQLEXPRESS;
initial catalog=ReGdb;
integrated security=True;
MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" /> </connectionStrings>
and here is my webhostdatabase connectionstring
Data Source=SQL5000322.Smarterasp.net;
Initial Catalog=DB_9BDB7789_ReGdb;
User Id=DB_9BDB7789_ReGdb_admin;
Password=happy;
hey bro you can modify your connection string this way and it must work. just copy and replace it with your connection string
<connectionStrings>
<add name="ReGdbEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;
provider=System.Data.SqlClient;
provider connection tring=quot;
datasource=SQL5000322.Smarterasp.net;
initial catalog=DB_9BDB7789_ReGdb;
User Id=DB_9BDB7789_ReGdb_admin;
Password=happy;
MultipleActiveResultSets=True;
App=EntityFramework""
providerName="System.Data.EntityClient" />
</connectionStrings>
here you go bro it must work
Pay attention to nested quotes:
provider connection string="data source=...

Entity Framework unable to find connection string in nested web.config

I'm new to .NET, but I'm using EntityFramework 5.0 and .NET 4.5
I have a website where the connectionStrings in the web.config are maintained in a configSource as follows:
<connectionStrings configSource="ConfigOverrides\overrideConnectionStrings.config">
</connectionStrings>
My website has modules with nested web.config files. These modules specify their own connectionStrings in the nested web.config. Everything was fine until I put a System.Data.EntityClient connection in my ConfigOverrides\overrideConnectionStrings file. After I did this I would get an error from the module:
No connection string named 'WebsiteEntities' could be found in the application config file.
If I copy the module's connectionString to the one in ConfigOverrides I get an error that there is already a connection string with that name. If I remove the connection string from their nested web.config and just put it in my overrides, it works. However I'm not wanting to maintain all module's connectionSettings in that global override.
Contents of overrideConnectionStrings.config:
<connectionStrings>
<add name="SqlServices" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=my_db;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\my_db.mdf;" />
<add name="TermsEntities" providerName="System.Data.EntityClient" connectionString="metadata=res://*/Terms.csdl|res://*/Terms.ssdl|res://*/Terms.msl;provider=System.Data.SqlClient;provider connection string='data source=(LocalDb)\v11.0;Initial Catalog=my_db;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\my_db.mdf;connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework'" />
<add name="ADServer" connectionString="LDAP://ldap.localdomain:389/DC=company,DC=com" />
</connectionStrings>
Contents of module's nested Web.config connectionStrings:
<connectionStrings>
<add name="WebsiteEntities" connectionString="metadata=res://*/WSE.csdl|res://*/WSE.ssdl|res://*/WSE.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=WSE_DB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="RoutingConn" providerName="System.Data.SqlClient" connectionString="data source=.;initial catalog=WSE_DB;integrated security=True;" />
</connectionStrings>
I should note that the module worked fine until I added my TermsEntities to the main site's web.config (via the ConfigOverrides).
I am still unable to figure out what in my application setup is causing the connectionString to not be found. While debugging I could view the connectionStrings available to the path of the request and I would see all connectionStrings (those in the nested web.config and those in the root web.config).
My workaround is to just use the ConfigurationManager from System.Configuration and read in the connection string :
public partial class WebsiteEntities : DbContext
{
public WebsiteEntities()
: base(ConfigurationManager.ConnectionStrings["WebsiteEntities"].ConnectionString ?? "name=WebsiteEntities")
{
}
...
This seems to be working.

SQL Server Connection String: Web Hosting Service providing connection string that doesn't seem right

I have an ASP.NET C# application with a SQL server 2008 R2 database that has consolidated membership provider and application database. I am trying to modify my web config according to the instructions provided by the web hosting service provider but I think I'm missing something.
Here is my current web.config connection strings:
<connectionStrings>
<add name="RestaurantDB" connectionString="data source=SFP\SFP_SQL_SVR;attachdbfilename=C:\Users\Susan\Documents\Databases\Restaurants.mdf;Integrated Security=SSPI;"/>
<add name="RestaurantsEntities" connectionString="metadata=res://*/Restaurant.csdl|res://*/Restaurant.ssdl|res://*/Restaurant.msl;provider=System.Data.SqlClient;provider connection string="data source=SFP\SFP_SQL_SVR;attachdbfilename=C:\Users\Susan\Documents\Databases\Restaurants.mdf;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
Here is the connection string that the web hosting service has given me:
Data Source=RESTAURANT.db.9319451.hostedresource.com; Initial Catalog=RESTAURANT; User ID=your username; Password='your password';
How do I modify my current connection strings in light of the above? Thanks in advance.
Just replace data source=SFP\SFP_SQL_SVR;attachdbfilename=C:\Users\Susan\Documents\Databases\Restaurants.mdf;Integrated Security=SSPI;
to
Data Source=RESTAURANT.db.9319451.hostedresource.com; Initial Catalog=RESTAURANT; User ID=your username; Password='your password';
Like :
<add name="RestaurantDB" connectionString="data source=RESTAURANT.db.9319451.hostedresource.com;
Initial Catalog=RESTAURANT; User ID=your username; Password='your password'>
<add name="RestaurantsEntities" connectionString="metadata=res://*/Restaurant.csdl|res://*/Restaurant.ssdl|res://*/Restaurant.msl;
provider=System.Data.SqlClient;provider connection string="Data Source=RESTAURANT.db.9319451.hostedresource.com;
Initial Catalog=RESTAURANT; User ID=your username; Password='your password;
multipleactiveresultsets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
I have no idea how to deal with this but I'm just giving you an idea. Try it may be it works
First modify your RestaurantDB connection string like this
<add name="RestaurantDB" connectionString="RESTAURANT.db.9319451.hostedresource.com;Initial Catalog=RESTAURANT; User ID=your username; Password='your password';"/>
and RestaurantsEntities like this
<add name="RestaurantsEntities" connectionString="metadata=res://*/Restaurant.csdl|res://*/Restaurant.ssdl|res://*/Restaurant.msl;provider=System.Data.SqlClient;provider connection string="data source=RESTAURANT.db.9319451.hostedresource.com;Initial Catalog=RESTAURANT;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
If the above does not work then also add UserID and Password in the RestaurantsEntities connection string

Categories

Resources