本文介绍了如何远程访问数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 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.91if i put 172.21.1.91 apart of PD-JANAKANis it okay?if i put 172.21.1.91it 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 immediatelycannot 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); } } }推荐答案 这篇关于如何远程访问数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-06 15:25