"defaultdblocation" not right in work thread when use sqlitedb.

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
5/22/2008 12:34:47 PM
Gravatar
Total Posts 59

"defaultdblocation" not right in work thread when use sqlitedb.

Hi, joe:

Below code in file dbModuleDefinition.cs of project mojoPortal.Data.SQLite .

///////////////////////////////////////////////////////////////////////////////////////

private static string GetConnectionString()
{
string connectionString = ConfigurationManager.AppSettings["SqliteConnectionString"];
if (
(connectionString == "defaultdblocation")
&& (HttpContext.Current != null) //When run in ThreadPool.QueueUserWorkItem, HttpContext.Current is null
)
{

connectionString = "version=3,URI=file:"
+ HttpContext.Current.Server.MapPath("~/Data/sqlitedb/mojoportal.db");

}
return connectionString;
}
///////////////////////////////////////////////////////////////////////////////

When run in ThreadPool.QueueUserWorkItem, HttpContext.Current is null, then "defaultdblocation" will not be translated to the right value, it is still "defaultdblocation", but it is should be translated in work thread too.

Thanks!


 

5/22/2008 12:46:36 PM
Gravatar
Total Posts 18439

Re: "defaultdblocation" not right in work thread when use sqlitedb.

Hi,

You are right, that is a problem. However, I'm not sure of a good solution because HttpContext is required in order to translate it using Server.MapPath

I will have to ponder a different solution.

In the meantime you can work around it by using a full connection string instead of defaultdblocation

Thanks,

Joe

5/22/2008 1:32:18 PM
Gravatar
Total Posts 18439

Re: "defaultdblocation" not right in work thread when use sqlitedb.

Hi,

Can you try this code and let me know if it works?

if (connectionString == "defaultdblocation")
            {

                connectionString = "version=3,URI=file:"
                    + System.Web.Hosting.HostingEnvironment.MapPath("~/Data/sqlitedb/mojoportal.db");

            }

Thanks,

Joe

5/23/2008 10:28:26 PM
Gravatar
Total Posts 59

Re: "defaultdblocation" not right in work thread when use sqlitedb.

Hi. Joe

    It works now.

    But too many places have the function GetConnectionString(),  why not merge them that only have only one copy GetConnectionString()?

Thanks!

You must sign in to post in the forums. This thread is closed to new posts.