Setup Elmah with MySQL? - asp.net

I have run the Elmah nuget package, copied the mysql.data.dll to the bin folder and run the mySQL script in the database but where do I state the address and login to the database?
Best regards

If you've already installed Elmah and created the tables in your database all your should need to do now is make sure the tables have the correct permissions then edit the connection string for Elmah in your web.config to include the username and password for whatever account you'll access the DB from the same as any other connection string but using the MysqlClient
In your web.config you should have something similar to:
<elmah>
<errorLog type="Elmah.MySqlErrorLog, Elmah" connectionStringName="Elmah.MySql" />
<security allowRemoteAccess="1" />
</elmah>
And also elsewhere in the connection strings bit something along the lines of:
<connectionStrings>
<add name="Elmah.MySql" connectionString="[STUFF HERE];User ID=[WHATEVER];Password=[WHATEVER];" providerName="System.Data.MySqlClient" />
</connectionStrings>

Related

How to get ELMAH to log to Mongodb?

i want to use Elmah to log errors into my mongodb database
i am using Asp.net mvc website
i have done following steps already
1.installed Elmah from nuget solution
and it successfully log erros in Elmah.axd page
now all i want is to log this errors in my mongodb database
can some one suggest me steps for that ?
You can use the elmah-mongodb package. Install the elmah.mongodb NuGet package and add the following to your web.confing file:
<elmah>
<errorLog type="Elmah.MongoErrorLog, Elmah.MongoDB" connectionStringName="elmah-mongodb" maxSize="10485760" maxDocuments="10000"/>
</elmah>
<connectionStrings>
<add name="elmah-mongodb" connectionString="mongodb://localhost/elmah?w=0"/>
</connectionStrings>

Have connection strings as well as common config source in asp.net or wcf websites

Hi I am looking for a solution where I have some common connection strings which I have
a common connections strings file but also need some specific add and remove connection strings in some sites...but do not see a way to do it...
<configuration>
<connectionStrings configSource="connections.config">
<remove name="AppConnectionString" />
<add name="AppConnectionString" connectionString="data source=(local);initial catalog=xyz;integrated security=True;MultipleActiveResultSets=True;" />
<connectionStrings/>
</configuration>
With file connections.config containing
<connectionStrings>
<add name="name" connectionString="conn_string" providerName="System.Data.SqlClient" />
<add name="name2" connectionString="conn_string2" providerName="System.Data.SqlClient" />
</connectionStrings>
Thanks,
Bala
If this does not work as you have expressed it above (which is a shame in my opinon), you have a number of other options:
Include the common connection strings in the connection string config, and then use the application settings config for the app-specific connection strings.
As an alternative, use a custom configuration file for the app-specific connection strings and load it in for each app.
When you build your apps inject the correct connection string keys into the config file using something like powershell. This script can run as a post build task in your build script.
Otherwise, when you package or stage your release, ask the release team to run the script as a manual step (or add it into your deployment script).

Environment variables in ASP.NET web.config file

I was wondering why can't I use a custom environment variable in an ASP.NET web.config file like so?
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="ConnectionName" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename='%MyProjectsFolder%\WebAppName\App_Data\Database1.mdf';User Instance=true" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
I checked through Start -> Run that the file path to .mdf file is valid.
When I run my C# code to connect to database I get the following error:
An attempt to attach an auto-named database for file
%MyProjectsFolder%\WebAppName\App_Data\Database1.mdf failed. A
database with the same name exists, or specified file cannot be
opened, or it is located on UNC share.
Environment variables may not be used in a config file.
You can use: DataDirectory like this:
“Data Source = |DataDirectory|\Mydb.sdf”
And you can change where DataDirectory points: "To set the DataDirectory property, call the AppDomain.SetData"
http://social.msdn.microsoft.com/Forums/en/sqlce/thread/dc31ea59-5718-49b6-9f1f-7039da425296
Caveat, I've never tried this.
I don't suppose you've tried:
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename='~/App_Data/Database1.mdf';User Instance=true"

Pre-Generating views to improve query performance in Entity Framework

I am trying to pre-generate view metadata for my Entity Framework project and have run across a problem on the last step when using this resource:
http://msdn.microsoft.com/en-us/library/bb896240.aspx
Everything else is compiling great, but I'm getting an error when I run my application, and I suspect it's due to a problem with the final step, 're-adding mapping and model files as embedded resources for ASP.NET projects.'
I'm receiving 'Unable to load the specified metadata resource.' and my connection string is as follows:
<add name="myEntities"
connectionString="metadata=
.\DataStructure.csdl|
.\DataStructure.ssdl|
.\DataStructure.msl;provider=System.Data.SqlClient;provider
connection string="Data Source=x;Initial Catalog=x;Persist Security Info=True;User ID=x;Password=x;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" />
It is suggested in the document that my connection string file should include the following but haven't been able to get it right in any configuration:
Metadata=res://<assemblyFullName>/<resourceName>;
Metadata=res://*/<resourceName>;
Metadata=res://*;
Assuming my assembly name is DataStructure.EF, how should my string be constructed?
http://msdn.microsoft.com/en-us/library/cc716756.aspx
<connectionStrings>
<add name="AdventureWorksEntities"
connectionString="metadata=.\AdventureWorks.csdl|.\AdventureWorks.ssdl|.\AdventureWorks.msl;
provider=System.Data.SqlClient;provider connection string='Data Source=localhost;
Initial Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60;
multipleactiveresultsets=true'" providerName="System.Data.EntityClient" />
</connectionStrings>
I compiled a full guide for anybody else having problems and published it here: http://kewney.com/posts/software-development/pre-generating-views-to-improve-query-performance-in-aspnet-mvc-3-entity-framework

ASP.NET Attempt to attach auto-named a database failed?

Parser Error Message: An attempt to
attach an auto-named database for file
D:\Projects\Damnation\Damnation.Website\Damnation.Website.Tracker\BugNET_WAP\App_Data\aspnetdb.mdf
failed. A database with the same name
exists, or specified file cannot be
opened, or it is located on UNC share.
Why could this be happening? My connection string doesn't use |DataDirectory|, it is:
<connectionStrings>
<add name="BugNET" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=dnmain;Integrated Security=True;"/>
</connectionStrings>
I get this error when I try to load default.aspx, after installing BugNET.
Apparently, and certainly for some obscure reason. There is a mistery connection string coming from... nowhere.
Problem solved adding a <clear/> tag.
<connectionStrings>
<clear/>
<add name="BugNET" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=dnmain;Integrated Security=True;"/>
</connectionStrings>
file
D:\Projects\Damnation\Damnation.Website\Damnation.Website.Tracker\BugNET_WAP\App_Data**aspnetdb.mdf**
failed.
This is the ASP.NET standard membership system here - not your "regular" database. There must be a second connection string somewhere that references this aspnetdb.mdf and tries to attach it from a file.
Search your solution for this file name - it must be somewhere!

Resources