小弟写了一个关于用户登陆连接到SQL数据库的封装类,调用调试的时候总出现
重载“SqlServerConnection1”方法未获取“1”参数
请各位大虾们帮忙看看问题出在那里了
代码如下:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace DatabaseConnect
{
public class SqlServerConnection1
{
private string uname = "";
private string pwd = "";
public SqlServerConnection1(string sqlserverconnection1Uname,string sqlserverconnection1Pwd)
{
this.uname = sqlserverconnection1Uname;
this.pwd = sqlserverconnection1Pwd;
}
public void denglu()
{
string conn = "server=SL;database=yuyin;user id=sa;pwd=";
SqlConnection cn = new SqlConnection(conn);
cn.Open();
string strsql = "select username,password from admin where username='" + uname + "' or password='" + pwd + "'";
SqlCommand cmd = new SqlCommand(strsql, cn);
SqlDataReader rd = cmd.ExecuteReader();
if (rd.Read())
{
if (rd.GetValue(0).ToString() == uname)
{
if (rd.GetValue(1).ToString() == pwd)
{
MessageBox.Show("登陆成功");
}
else
{
MessageBox.Show("密码错误!");
}
}
else
{
MessageBox.Show("用户名错误!");
}
}
else
{
MessageBox.Show("用户不存在!");
}
}
}
}