我发现前两个的错误的地址是我自己机器的地址 ,SQLHelperBLL是我WTi_BLL的一个类,我检查了14,行。代码是
string connectstr = ConfigurationManager.ConnectionStrings["Connectstr"].ConnectionString;
这个怎么解决啊????
堆栈跟踪:
[NullReferenceException: 未将对象引用设置到对象的实例。]
WTi_BLL.SQLHelperBLL..ctor() in D:\WTi_HR7-25\WTi_BLL\SQLHelperBLL.cs:14
WTi_HR.Login..ctor() in D:\WTi_HR7-25\WTi_HR\Login.aspx.cs:20
ASP.login_aspx..ctor() +10
__ASP.FastObjectFactory_app_web_jto_qd43.Create_ASP_login_aspx() +20
System.Web.Compilation.BuildResultCompiledType.CreateInstance() +49
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +115
System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +31
System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +40
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +139
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +120
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
------解决方案--------------------
哪就得换种方式了。
简单点儿还是
EnableEventValidation="false"
确保你的web.config 有Connectstr值
写在web.config中
后台获取的时候用
configurationManager.connectionString["Connectstr"].ToString()
Web.config中加入
- XML code
<connectionStrings> <add name="Connectstr" connectionString="Data Source=.;Initial Catalog=数据库名字;User ID=账号;Password=密码" providerName="System.Data.SqlClient" /> </connectionStrings>