string connstr = @"Data Source=.sqlexpress;Initial Catalog=数据库名;Integrated Security=True"; SqlConnection conn = new SqlConnection(connstr); string sql = "select * from admin where username= + user + and pwd= + pwd + "; SqlCommand cmd = new SqlCommand(sql, conn); int x=cmd.ExecuteNonQuery(); if (x > 0) { //登陆成功! } else { //登陆失败! }C#Windows应用程序登陆界面如何连接到SQL数据库验证用户名和用户密码,我要详细代码……
温馨提示:答案为网友推荐,仅供参考