我已经从一个朋友那里继承了一个网站来托管,因为他和目前的人为他托管时发生了冲突。
它是一个旧站点,从外观上看它是IIS7托管的,我无法在线获取它。
我在带有IIS的服务器2012r2机器上
基本上这是我得到的错误:
The ConnectionString property has not been initialized.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized.
Source Error:
Line 95:
Line 96: conOleDbConnection = New SqlConnection(ConfigurationManager.ConnectionStrings.Item("SQLClient").ConnectionString)
Line 97: conOleDbConnection.Open()
Line 98:
Line 99: dadOleDbDataAdapter = New SqlDataAdapter(strSQL, conOleDbConnection)
Source File: C:\inetpub\wwwroot\abc\App_Code\SqlClient.vb Line: 97
Stack Trace:
[InvalidOperationException: The ConnectionString property has not been initialized.]
System.Data.SqlClient.SqlConnection.PermissionDemand() +7116997
System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection) +30
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +312
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +202
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +413
System.Data.SqlClient.SqlConnection.Open() +128
BBS.SqlClient.DataHandler.GetDataTable(String strSQL) in C:\inetpub\wwwroot\abc\App_Code\SqlClient.vb:97
BBS.SqlClient.DataHandler.GetDataRow(String strSQL) in C:\inetpub\wwwroot\abc\App_Code\SqlClient.vb:128
BBS.Sql.AbstractEntity.LoadObjectByCol(String strColumnName, String strColumnValue) in C:\inetpub\wwwroot\abc\App_Code\AbstractEntity.vb:216
_Default.Bind(String strWebPageURL) in C:\inetpub\wwwroot\abc\Default.aspx.vb:9
_Default.Page_Load(Object s, EventArgs e) in C:\inetpub\wwwroot\abc\Default.aspx.vb:30
System.Web.UI.Control.OnLoad(EventArgs e) +106
System.Web.UI.Control.LoadRecursive() +68
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3785
这是堆栈跟踪文件的相关部分:
SQLCLIENT.VB第97行
Public Shared Function GetDataTable(ByVal strSQL As String) As DataTable
Dim conOleDbConnection As SqlConnection
Dim dadOleDbDataAdapter As SqlDataAdapter
Dim dstDataSet As New DataSet
conOleDbConnection = New SqlConnection(ConfigurationManager.ConnectionStrings.Item("SQLClient").ConnectionString)
conOleDbConnection.Open()
dadOleDbDataAdapter = New SqlDataAdapter(strSQL, conOleDbConnection)
dadOleDbDataAdapter.Fill(dstDataSet, "Data")
conOleDbConnection.Close()
conOleDbConnection = Nothing
Return dstDataSet.Tables("Data")
End Function
SQLCLIENT.VB第128行
Public Shared Function GetDataRow(ByVal strSQL As String) As DataRow
Dim dtblGetDataRow As DataTable = GetDataTable(strSQL)
If dtblGetDataRow.Rows.Count = 1 Then Return dtblGetDataRow.Rows(0) Else Return Nothing
End Function
这是从web.config提供的连接字符串
<connectionStrings>
<add connectionString="" name="SQLClient" />
</connectionStrings>
已将数据库放置到MSSQL服务器上
尝试添加新的连接字符串:
<add name="MSSQL" connectionString="Data Source=abc;Initial Catalog=def Name;User id=geh;Password=ijk;Persist Security Info=true;Pooling=true" providerName="System.Data.SqlClient"/>
但随后所有种类都会出错。
有人可以帮我使该网站恢复在线吗?
预先感谢
答案 0 :(得分:1)
您的连接字符串为空,并将连接从SQLClient重命名为MSSQL。
使用SSMS来检查
Data Source=<sqlservername>;Initial Catalog=<database>;Integrated Security=True
...,其中
答案 1 :(得分:0)
我想知道ConfigurationManager.ConnectionStrings.Item(“ SQLClient”)。ConnectionString是否实际上返回了什么。通过查看您的代码,SQLClient没有太多内容。它应该看起来像这样。
<connectionStrings>
<add name="SQLClient" connectionString="Data Source=abc;Initial Catalog=def Name;User id=geh;Password=ijk;Persist Security Info=true;Pooling=true" />
</connectionStrings>
我认为如果连接字符串实际上是错误的,您将得到另一个错误。
答案 2 :(得分:0)
您添加了一个新的连接字符串,但是名称不同。配置文件中的名称必须与代码正在寻找的名称(“ SQLClient”)匹配。
dict_b = defaultdict(list)
dict_b['b'].append(b1.to_dict())
dict_b['b'].append(b2.to_dict())
print(json.dumps(dict_b))
您可以摆脱<connectionStrings>
<add connectionString="you need to put something here" name="SQLClient" />
</connectionStrings>
。从中获取connectionString并将其放在SQLClient条目中。或从MSSQL重命名为SQLClient并丢弃多余的内容。
答案 3 :(得分:0)
前一个家伙显然是通过删除整行而不是仅仅删除细节来删除他的细节。使用会启动网站。
感谢the_lotus和Mason向我指出了正确的方向。