如何远程访问数据库?

问题描述:

PD-JANAKAN是我的服务器名称....

我的IP地址是172.21.1.91



如果我输入172.21。 1.91分PD-JANAKAN

好​​吗?



如果我把172.21.1.91

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



无法打开登录请求的数据库EnqInfo。登录失败。用户Hemas\itcordinator.travels登录失败。



Hemas\itcordinator.travels =这意味着我要从中访问数据库的另一台计算机。





PD-JANAKAN is my server name....
my ip address is 172.21.1.91

if i put 172.21.1.91 apart of PD-JANAKAN
is it okay?

if i put 172.21.1.91
it ll say unhandled exception has occured in your application. the application will ignore this error and attempt to ontinur. if you click quit the application will close immediately

cannot open database "EnqInfo" requested by the login. the login failed. Login failed for user "Hemas\itcordinator.travels".

Hemas\itcordinator.travels = this mean the other computer which i goin to access the database from.


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

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

            connetionString = "Data Source=PD-JANAKAN;Initial Catalog=EnqInfo;Integrated Security=True";


            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);
                        }
                    }
                }



这个表示您的Windows身份验证用户标识无权访问该数据库。您可以通过常见的SQL身份验证登录服务器,或尝试提供对NT Authority System的访问权限并获取对Windows身份验证的访问权限。



感谢和问候,>
Mathi。
Hi,
This means your Windows authentication user ID doesn't have access to the DB. You can login to the server via a common SQL authentication or try providing access to NT Authority System and get access to the Windows authentication.

Thanks & Regards,
Mathi.


继续解决方案1 ​​ - 我不相信您的连接字符串 - 请查看此处的详细信息... https://www.connectionstrings.com/sql-server/ [ ^ ]
Further to Solution 1 - I'm not convinced by your connection string - check out the details here ... https://www.connectionstrings.com/sql-server/[^]