问题描述
我想在ASP.NET中创建C#简单的登录页面,但我收到的一些错误。
I am trying to create a simple login page in ASP.NET C# but am getting some error.
我GOOGLE有关错误,并试图全部的解决方案,但都无济于事。
我究竟做错了什么?该错误是:
I googled about the error, and tried all the solutions but to no avail.What am I doing wrong? The error is:
发生网络相关的或特定于实例的错误,服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server配置为允许远程连接。 (提供者:SQL网络接口,错误:26 - 错误定位服务器/实例指定)
我觉得它的东西与我的连接字符串是如下:
I think it's something to do with my connection string which is as follows:
<add name="cn"
connectionString="server=HCL;DataBase=GS;Integrated Security=True" />
HCL是通过LAN与该数据库,GS连接到我的PC另一台机器,驻留在其上。是我在上面code的服务器属性来给出值的问题?如果没有什么别的可我是做错了?
"HCL" is another machine connected to my PC through the LAN and this database, "GS", resides on it. Is the problem with the value I am giving in "Server" attribute of the above code? If not what else may I be doing wrong?
我可以告诉所有的解决方案我试过了。让如果这是需要我。
I can tell all solutions I tried. Let me know if that's required.
推荐答案
我不认为服务器是一个连接字符串的有效属性。尝试数据源来代替。 综合安全也应设置为SSPI:
I don't think "Server" is a valid property for a connection string. Try "Data Source" instead. "Integrated Security" should also be set to SSPI:
<add name="cn" connectionString="Data Source=HCL;Initial Catalog=GS;Integrated Security=SSPI"/>
更新:
我只注意到你也用数据库。这应该是初始目录。
UPDATE:I just noticed that you have also used "Database". This should be "Initial Catalog".
UPDATE2:
有一种通过使用.UDL文件创建连接字符串一个巧妙的花招。如果创建一个名为something.udl并双击它一个空文件,Windows会打开一个很好的对话框用于定义连接。要创建一个SQL Server的连接字符串,选择SQL Server的Microsoft OLEDB提供程序中的提供者选项卡,然后填写你的服务器名称,登录凭据,并在连接选项卡上的数据库名称。通过测试连接,然后单击Finish(完成)OK。
UPDATE2:There is a neat trick for creating connection strings by using .udl files. If you create an empty file called "something.udl" and double click it, Windows will open a nice dialog for defining connections. To create a connection string for a SQL Server, choose "Microsoft OLEDB Provider for SQL Server" on the "Provider" tab and then fill in your server name, login credentials, and database name on the "Connection" tab. Finish by testing the connection and click "OK".
后,您可以拖动.udl文件到记事本或Visual Studio,你会看到.udl文件实际上包含一个连接字符串供您使用(注意,如果你希望使用的连接字符串的SqlConnection
在.net中,您必须删除提供= SQLOLEDB.1字符串的一部分)。
After the dialog is closed, you can drag the .udl file into Notepad or Visual Studio and you will see that the .udl file actually contains a connection string ready for you to use (note that if you wish to use the connection string with SqlConnection
in .NET you must remove the "Provider=SQLOLEDB.1" part of the string).
这篇关于ASP.NET初学者的问题:如何摆脱这种错误的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!