我试图通过Filezilla部署我的站点。我已经在sql server 2012中创建了数据库,并将我的visual studio与sql server连接起来。当我在本地服务器上运行它时,它可以很好地工作,我可以很容易地登录和签出,但是当我在web上部署它时,它在con.open()行上显示了这个错误。请帮帮忙。
描述:在执行当前web请求时发生了未处理的异常。请查看堆栈跟踪以获得有关错误的更多信息,以及它起源于代码的位置。
异常详细信息: System.ComponentModel.Win32Exception:未找到网络路径。
public partial class signinregistration : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click1(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=ISL-4;Initial Catalog=Cruisedb;Integrated Security=True");
con.Open();
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM [Login] WHERE Email = @email AND Password = @password", con);
using (con)
{
sda.SelectCommand.Parameters.AddWithValue("@email", this.textboxemail.Text);
sda.SelectCommand.Parameters.AddWithValue("@password", this.textboxpassword.Text);
sda.Fill(dt);
if (dt.Rows.Count == 0)
{
textboxemail.Text = "";
textboxpassword.Text = "";
Label3.Visible = true;
return;
}
string txt = textboxemail.Text;
Session["Email"] = txt;
Response.Redirect("index.aspx");
}
}
}源文件: 27..line 27行是con.open()。
堆栈跟踪:
[Win32Exception (0x80004005): The network path was not found]
[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
+5341995
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +546
System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) +5353703
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +145
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +892
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +311
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData) +646
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +278
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +38 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +732
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +85
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +1057
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +78
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +196
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +146
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +16
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +94
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +110
System.Data.SqlClient.SqlConnection.Open() +96
signinregistration.Button1_Click1(Object sender, EventArgs e) in \\smb-whst-www02\whst_www02$\ff8b1b\user\fareshoppers.co.uk\web\signinregistration.aspx.cs:27 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9628462
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724@MachineLearning
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=ISL-4;Initial Catalog=Cruisedb;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<customErrors mode="Off"/>
</system.web>
</configuration>发布于 2016-08-30 08:01:19
当您使用FileZilla部署您的网站时,它会将所有web应用程序文件复制到ftp文件夹中,但是您的数据库不会被复制,因为它不在web项目的路径中。您将在以下文件夹中找到您的数据库文件(.mdf、.ldf等)
C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data
但是,您仍然不能将数据库文件复制到服务器上并使用它们,因为数据库文件是由Server提供的,因此您的服务器(主机)上的SQL server将被告知数据库。
这方面的第一个要求是,您的主机提供商应该为您提供MS数据库。如果您当前的提供商没有提供服务,那么您应该另找一个可以只提供MS数据库或与MS数据库一起托管的人(您可以计算出这些选项的财务状况)。
当宿主提供商为您提供MS数据库时,您必须登录到宿主控制面板并导航到MS选项(在宿主提供商的控制面板中可以调用的任何内容)。在那里,您可以选择附加现有的数据库文件,或者将一个新的数据库放入机箱并运行查询。
如果可以附加数据库
如果宿主服务提供商要求您创建新的数据库,则为。
对于上述两种情况,您将/可能必须根据需要更改连接字符串(根据数据库名称、创建的用户名及其密码)。
希望这能有所帮助。
https://stackoverflow.com/questions/39219550
复制相似问题