如何在不安装Sql Server的情况下远程访问网络中的数据库? [英] How Do I Remotely Access My Database Within Network Without Installing Sql Server?

查看:110
本文介绍了如何在不安装Sql Server的情况下远程访问网络中的数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个程序,该程序的第一阶段是使用用户名和密码登录该应用程序。



所以现在我要打开exe文件来自另一台连接到网络的电脑,它也没有sql。



当我点击exe按钮时会询问用户名和密码....我们输入用户名和密码然后点击输入它必须连接到sql安装的pc。



i have created a program and first stage of that program is to login to that application using username and password.

so now i want to open exe file from another pc which connected to network and it doesn't have sql as well.

when i click exe button it will ask user name and password.... and when we enter user name and password and hit enter it has to connect to sql installed pc.

private void Btn1_Click(object sender, EventArgs e)
        {
            string connetionString = null;

            //string sql = null;
            string name = "";
            string pass = "";

            connetionString = "Data Source=172.21.1.91;Initial Catalog=EnqInfo;Network Library=DBMSSOCN;User Id=username; Password=password;Integrated Security=SSPI";


            using (SqlConnection con = new SqlConnection(connetionString))
            {
                //
                // Open the SqlConnection.
                //
                con.Open();
                //
                // The following code uses an SqlCommand based on the SqlConnection.
                //
                using (SqlCommand command = new SqlCommand("SELECT * FROM Login WHERE U_Name=@Usr", con))
                    {

                        command.Parameters.AddWithValue("@Usr", UName.Text);
                        SqlDataReader reader = command.ExecuteReader();
                        while (reader.Read())
                        {
                            name = reader.GetString(1);  // Name string
                            pass = reader.GetString(2); // Password string
                        }

                        if (name == UName.Text && pass == PWord.Text)
                        {

                            ClassEnq.Uname = UName.Text;
                            MessageBox.Show("Password Accepted");
                            this.Close();
                            setEnableToolStripMenuItem(true);
                            setEnableToolStripMenuItem1(true);
                            setDisableToolStripMenuItem(false);

                        }

                        else
                        {
                            MessageBox.Show("Password Incorrect, Please Re-Enter Your Password");
                            setEnableToolStripMenuItem(false);
                            setEnableToolStripMenuItem1(false);
                        }
                    }
                }







这是我的代码........



这是我的错误....



您的应用程序中发生了未处理的异常。如果单击继续,应用程序将忽略此错误并尝试继续。如果单击退出,应用程序将立即关闭。



建立与SQL Server的连接时发生网络相关或特定于实例的错误。服务器未找到或无法访问。验证intance名称是否正确以及sql server是否配置为允许远程连接。 (提供商:TCP提供商,错误:0-A连接尝试提交,因为连接方在一段时间后没有正确响应,或者由于连接主机未能响应而建立连接失败)。





请给我任何好的解决方案。我做了一切,但仍然有问题。



i之前也注意到了这个问题。




this is my code........

this is my error....

Unhandled exception has occurred in your application. if you click continue, the application will ignore this error and attempt to continue. if you click quit, the application will close immediately.

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 intance name is correct and that sql server is configured to allow remote connection. (provider: TCP Provider, error: 0-A connection attempt filed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond).


please provide me any good solution. i did everything but still has issues.

i noted this problem previously as well.

推荐答案

有连接失败的几个可能原因。请看看这些:

- http://www.sswug。 org / articlesection / default.aspx?TargetID = 44331 [ ^ ]



- http://stackoverflow.com/questions/18060667/cannot-connect-to-server-a-network-related-or-instance-specific-error [ ^ ]



- http: //support.microsoft.com/kb/287932 [ ^ ]
There are several possible reasons for the connection to fail. Please have a look at these:
- http://www.sswug.org/articlesection/default.aspx?TargetID=44331[^]

- http://stackoverflow.com/questions/18060667/cannot-connect-to-server-a-network-related-or-instance-specific-error[^]

- http://support.microsoft.com/kb/287932[^]


根据您的问题,这意味着您需要从您的应用程序中使用来自其他网络pc的sql server。因为您应该更改 ConnectionString 并在SQL服务器上进行一些配置用于远程连接的Surface Area 。我已经实现了这个并从远程PC获取访问权限。



请点击链接:



http://searchsqlserver.techtarget.com/tip/Using-Surface-Area-Configuration- to-lock-down-SQL-Server [ ^ ]



http://www.scrumdesk.com/Articles/HowToEnableSQLServerRemoteConnections.html [ ^ ]
As per your question it means that you need to use sql server from another network pc from your application. For you should change ConnectionString and make some configuration on SQL server Surface Area for remote connection. Already I implement this and get access from remote pc.

Please follow the links:

http://searchsqlserver.techtarget.com/tip/Using-Surface-Area-Configuration-to-lock-down-SQL-Server[^]

http://www.scrumdesk.com/Articles/HowToEnableSQLServerRemoteConnections.html[^]


这篇关于如何在不安装Sql Server的情况下远程访问网络中的数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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