简体   繁体   English

无法从托管的ASP.NET应用访问SQL Server

[英]SQL Server not accessible from hosted ASP.NET app

I'm facing a problem with the deployment of an ASP .NET web application. 我在部署ASP .NET Web应用程序时遇到问题。

I uploaded project in somee.com (it provides free hosting services for ASP web applications). 我在somee.com中上传了项目(它为ASP Web应用程序提供免费的托管服务)。 The url for the site is www.ipcboss.somee.com. 该网站的网址是www.ipcboss.somee.com。 Please go through this link and enter data for login and password. 请通过此链接输入登录名和密码的数据。 It has to display an alert message; 它必须显示警报消息; if login credencials are correct it goes to some other page. 如果登录凭据正确,则会转到其他页面。

I'm getting an SQL instance error server not found error number 26 occurring. 我正在获取一个SQL实例错误服务器,未发现发生的错误号26。 I changed the sql server path to the workstation path that is provided by somee.com in the web.config file. 我将sql服务器路径更改为web.config文件中somee.com提供的工作站路径。 I uploaded database file .mdf format to the database provided by somee.com. 我将数据库文件.mdf格式上传到somee.com提供的数据库中。 I tried so many ways but I didn't get the solution. 我尝试了很多方法,但没有得到解决方案。 the connection string is 连接字符串是

connectionString="workstation id=ipcsampledb.mssql.somee.com;packet size=4096;user id=yarrasuresh9999_SQLLogin_1;pwd=mypassword;data source=ipcsampledb.mssql.somee.com;persist security info=False;initial catalog=ipcsampledb"
   providerName="System.Data.SqlClient"

use this as a connection string.. 使用它作为连接字符串。

<add name="ConnectionString" connectionString="Data Source=ipcsampledb.mssql.somee.com;Initial Catalog=ipcsampledb;User ID=yarrasuresh9999_SQLLogin_1;Password=pd4idnkycx"
          providerName="System.Data.SqlClient" />

it will solve your problem. 它会解决您的问题。

// I uploaded database file .mdf format to the database provided by somee.com.// //我将数据库文件.mdf格式上传到somee.com提供的数据库中。

You need to figure out if your hosting company wants you to use this type of connection 您需要弄清楚托管公司是否希望您使用这种类型的连接

AttachDbFilename AttachDbFilename

or not. 或不。

Ok. 好。 Uploading a mdf file doesn't automatically register the database. 上载mdf文件不会自动注册数据库。 So sometimes you "initiate a registration" by using the AttachDbFilename syntax. 因此,有时您可以使用AttachDbFilename语法“启动注册”。

Other times, the mdf you upload has to be "wired into" a running instance of Sql Server. 有时,您上传的mdf必须“连接”到正在运行的Sql Server实例中。 When this happens, you will NOT use the AttachDbFilename syntax. 发生这种情况时,将不会使用AttachDbFilename语法。

There is no reason to "guess". 没有理由“猜测”。 Ask your hoster for an example connection string. 向您的托管人询问示例连接字符串。

If they give you a non AttachDbFilename syntax, then ask them how your uploaded mdf file gets registered by sql server. 如果他们为您提供非AttachDbFilename语法,请询问他们如何通过sql server注册您上传的mdf文件。

Create a udl file, if it connects then the problem is the code / application, if it does not connect, then it's your firewall, connections string, dll library, service you are running IIS under not having the right permissions etc etc. Well the important thing here is probably the connection string. 创建一个udl文件,如果连接,则问题是代码/应用程序,如果未连接,则是防火墙,连接字符串,dll库,在没有正确权限的情况下运行IIS的服务等。重要的是连接字符串。 Do the following: create an empty text file and rename it "myconnection.udl". 请执行以下操作:创建一个空文本文件,并将其重命名为“ myconnection.udl”。 Now double click on the file and it will launch an applet. 现在双击该文件,它将启动一个applet。 You can configuer the connection to your database and test it. 您可以配置与数据库的连接并进行测试。 (it will pick up registered connection libraries etc). (它将获取注册的连接库等)。 If it give OK, then open the udl file in notepad, you will see the correct connection string. 如果显示为OK,则在记事本中打开udl文件,您将看到正确的连接字符串。 Paste to your app connection settings. 粘贴到您的应用程序连接设置。 UDL files are generally misunderstood. UDL文件通常被误解。 They are simply a text file that holds the connection settings. 它们只是一个保存连接设置的文本文件。 They then call the connection dll. 然后,他们将调用连接dll。 If the udl file works then you have a correct connection string 100% 如果udl文件有效,那么您有正确的连接字符串100%

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM