babgvant / elmah

Automatically exported from code.google.com/p/elmah
Apache License 2.0
0 stars 0 forks source link

SqlServerCompactErrorLog doesn't resolve ~ in connection string #225

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Add this to web.config in a new project:
    <connectionStrings>
        <add name="ElmahDatabaseConnectionString1" connectionString="Data Source=~/App_Data/errors.sdf" />
        <add name="ElmahDatabaseConnectionString2" connectionString="Data Source=|DataDirectory|/errors.sdf" />
    </connectionStrings>
    <elmah>
        <errorLog type="Elmah.SqlServerCompactErrorLog, Elmah" connectionStringName="ElmahDatabaseConnectionString1" />
    </elmah>
2. Try to load the elmah.axd page in your browser.

What is the expected output? What do you see instead?

When using the ~ root operator, Elmah 1.2 throws a SqlCeException with error 
message: The path is not valid. Check the directory for the database. [ Path = 
~/App_Data/errors.sdf ]

When using the |DataDirectory| macro, it tries to create the database file as 
/errors.sdf (when it should be /App_Data/errors.sdf).

Original issue reported on code.google.com by let...@gmail.com on 10 May 2011 at 3:30

GoogleCodeExporter commented 8 years ago

Original comment by azizatif on 10 May 2011 at 6:57

GoogleCodeExporter commented 8 years ago
This is not valid syntax:
"Data Source=|DataDirectory|/errors.sdf"

- should be a backslash, not forward slash.

Original comment by ejls...@hotmail.com on 10 May 2011 at 8:13

GoogleCodeExporter commented 8 years ago
Thanks, you're correct: changing it to a backslash allows the |DataDirectory| 
macro to work correctly :)

The ~ operator still causes an exception though. I was able to get that syntax 
working in my project by changing
  string connectionString = ConnectionStringHelper.GetConnectionString(config);
in the SqlServerCompactErrorLog(IDictionary) constructor to
  string connectionString = ConnectionStringHelper.GetConnectionString(config, true);
(so its called the same way as in SQLiteErrorLog) and rebuilding Elmah.

Original comment by let...@gmail.com on 10 May 2011 at 8:42

GoogleCodeExporter commented 8 years ago
Yes, and there is another releated fix in the other constructor. I will commit 
an update soon...

Original comment by ejls...@hotmail.com on 10 May 2011 at 9:01

GoogleCodeExporter commented 8 years ago
Fixed in r853

Original comment by ejls...@hotmail.com on 10 May 2011 at 2:06

GoogleCodeExporter commented 8 years ago

Original comment by azizatif on 10 May 2011 at 3:12

GoogleCodeExporter commented 8 years ago
@lethek Have you tested the fix?

Original comment by azizatif on 11 May 2011 at 12:12

GoogleCodeExporter commented 8 years ago
I've now tested it, it works perfectly :) Thanks!

Original comment by let...@gmail.com on 11 May 2011 at 1:32

GoogleCodeExporter commented 8 years ago

Original comment by azizatif on 31 May 2011 at 6:58