网站无法与服务器上的SQL建立连接 [英] Website cannot establish connection to the SQL on server

查看:224
本文介绍了网站无法与服务器上的SQL建立连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该网站在我的本地计算机上运行得非常好。但是当我把它上传到服务器时。



然后运行登录或注册按钮它会说这个



System.ComponentModel.Win32Exception:拒绝访问

1.建立与SQL Server的连接时发生网络相关或特定于实例的错误。



2.未找到服务器或无法访问服务器。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。 (提供者:SQL网络接口



3.error:56 - 无法从注册表中指定的位置加载SQLUserInstance.dll。验证本地数据库运行时功能SQL Server Express已正确安装







这可能是因为本地计算机中的过滤器文件是这个



The website runs perfectly fine on my local computer. but when i upload it to the server.

and run the login or register button it says this

System.ComponentModel.Win32Exception: Access is denied
1. A network-related or instance-specific error occurred while establishing a connection to SQL Server.

2.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: SQL Network Interfaces

3.error: 56 - Unable to load the SQLUserInstance.dll from the location specified in the registry. Verify that the Local Database Runtime feature of SQL Server Express is properly installed



could this be because the filter file in my local computer is this

<pre lang="c#"> [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method,  AllowMultiple = false, Inherited = true)]
    public sealed class InitializeSimpleMembershipAttribute : ActionFilterAttribute
    {
        private static SimpleMembershipInitializer _initializer;
        private static object _initializerLock = new object();
        private static bool _isInitialized;

        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            // Ensure ASP.NET Simple Membership is initialized only once per app start
            LazyInitializer.EnsureInitialized(ref _initializer, ref _isInitialized, ref _initializerLock);
        }

        private class SimpleMembershipInitializer
        {
            public SimpleMembershipInitializer()
            {
                Database.SetInitializer<UsersContext>(null);

                try
                {
                    using (var context = new UsersContext())
                    {
                        if (!context.Database.Exists())
                        {
                            // Create the SimpleMembership database without Entity    Framework migration schema
                            ((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
                        }
                    }

                    WebSecurity.InitializeDatabaseConnection("DefaultConnection",  "UserProfile", "UserId", "UserName", autoCreateTables: true);
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException("The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", ex);
                }
            }
        }















可能因为WEBSECURITY.INITIALISE DATABASECONNECTION包含我本地计算机的默认连接而不是服务器..如果有人告诉我如何更改它



我尝试过的事情:



我已尝试添加



在web.config下


.





COULD THIS BE BECAUSE THE WEBSECURITY.INITIALISE DATABASECONNECTION CONTAINS THE DEFAULT CONNECTION OF MY LOCAL COMPUTER AND NOT OF THE SERVERS..IF SO CAN SOMEONE TELL ME HOW TO CHANGE IT

What I have tried:

I HAVE TRIED ADDING

under web.config

<system.web>
<customerrors mode="Off" />
</system.web>





允许远程连接



我该怎么做服务器端才能删除问题



for allowing remote connection

what should i do server side for the problem to be removed

推荐答案

使用连接字符串你正在使用web服务器无法访问SQL服务器。如果连接字符串指向localhost,那么SQL Server和数据库也需要在Web服务器上。请参阅webhost中有关SQL Server所在位置以及应该使用的连接字符串的文档。



如果在本地和已发布的服务器上需要不同的连接字符串然后使用web.config转换(google示例)确保在发布网站时使用正确的字符串。
With the connection string you're using the web server can't access the SQL Server. If the connection string is pointing to "localhost" then the SQL Server and database needs to be on the web server too. Consult the documentation from your webhost about where your SQL Server is and what connection string you should be using to it.

If you need different connection strings on local and published server then use web.config transformations (google for examples) to ensure the right string is used when the site is published.


这篇关于网站无法与服务器上的SQL建立连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆