问题描述
报错:SqlConnectionconn=newSqlConnection();行105:行106:conn.ConnectionString=ConfigurationManager.ConnectionStrings["connectString"].ToString();行107:行108:源文件:d:OA数据备份20101217OA数据备份20101217OA8000OAsystemadminttAddNews.aspx.cs行:106堆栈跟踪:[NullReferenceException:未将对象引用设置到对象的实例。]admin_tt_AddNews.AddRoot()ind:OA数据备份20101217OA数据备份20101217OA8000OAsystemadminttAddNews.aspx.cs:106admin_tt_AddNews.Page_Load(Objectsender,EventArgse)ind:OA数据备份20101217OA数据备份20101217OA8000OAsystemadminttAddNews.aspx.cs:18System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtrfp,Objecto,Objectt,EventArgse)+14System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Objectsender,EventArgse)+35System.Web.UI.Control.OnLoad(EventArgse)+99System.Web.UI.Control.LoadRecursive()+50System.Web.UI.Page.ProcessRequestMain(BooleanincludeStagesBeforeAsyncPoint,BooleanincludeStagesAfterAsyncPoint)+627web.config代码<appSettings><addkey="FCKeditor:BasePath"value="~/FCKeditor/"/><addkey="FCKeditor:UserFilesPath"value="~/uploadFiles"/><addkey="imagesfolder"value="~/File/"/><addkey="yuanimg"value="~/File/"/><addkey="ActiveTimeout"value="30"/><addkey="RefreshTimeout"value="1"/><addkey="refreshUrl"value="Refresh.aspx"/><addkey="ConnectionString"value="DataSource=LENOVO-PCSQL2005;InitialCatalog=OAs;PersistSecurityInfo=True;UserID=sa;Password=123456"/></appSettings><connectionStrings><addname="OAsystemConn"connectionString="DataSource=LENOVO-PCSQL2005;InitialCatalog=OAs;UserID=sa;Password=123456"providerName="System.Data.SqlClient"/><addname="OAsystemConnectionString1"connectionString="DataSource=LENOVO-PCSQL2005;InitialCatalog=OAs;UserID=sa"providerName="System.Data.SqlClient"/>求帮助!!
解决方案
解决方案二:
conn.ConnectionString=ConfigurationManager.ConnectionStrings["OAsystemConn"].ConnectionString;
解决方案三:
orConfigurationManager.AppSettings["ConnectionString"].ToString()
解决方案四:
楼上的说明很清楚了不要混淆,张冠李戴就行了。
解决方案五:
还是不行!!会是虚拟路径路径的问题么?没有读到web.config?
解决方案六:
引用4楼的回复:
还是不行!!会是虚拟路径路径的问题么?没有读到web.config?
按楼上改了报什么错
解决方案七:
跟原来的一样