VTemplate to correctly identify the relative increase access database file path

Recently used in the project to VTemplate, dataReaderTag label which provides the ability to provide direct access to the database, the internal database of parsing connection provides a packaging operation. But can not be used when accessing the access relative path, so to find his operation database file, find the class DataReaderTag in the GetDataSource () method.

Add code block using (DbConnection dbConnection = dbFactory.CreateConnection ()) in

                string str, str2, str3;
                str = str2 = str3 = setting.ConnectionString;
                if (setting.ProviderName == "System.Data.OleDb")
                {
                    System.Web.UI.Page page = new System.Web.UI.Page();
                    str2 = str.Substring(str.IndexOf("App_Data"));
                    str = page.Server.MapPath(str2);
                    str3 = str3.Replace(str2, str);
                    dbConnection.ConnectionString = str3;
                }
                else
                {
                    dbConnection.ConnectionString = setting.ConnectionString;
                }

This allows normal access using a relative path in the configuration file

Reproduced in: https: //www.cnblogs.com/tufan/archive/2010/06/11/1756251.html

Guess you like

Origin blog.csdn.net/weixin_33912246/article/details/93643041