0
나는 Visual Studio 2008을 사용하여 Windows 응용 프로그램을 만듭니다. 연결이 끊긴 방식으로 로그인 양식을 만들고 싶습니다. DataTable이 채워지는지 검사하려고 할 때 항상 채워지는 것을 보여주는 문제에 직면하고 있습니다. 로그인 버튼연결이 끊긴 구조의 로그인 양식 C#
는코드 :
귀하의 오류가 체크에있다try
{
//getting connectionString
mcc = new myConnectionClass();
conString = mcc.MyConnection;
//opening connection con
con = new SqlConnection(conString);
string queryString = "select * from LOGIN_TABLE where LOGIN_ID = @LOGIN_ID and LOGIN_PASSWORD = @LOGIN_PASSWORD";
//dataset ds , SqlDataAdapter sda
ds = new DataSet();
sda = new SqlDataAdapter();
//sqlcommand
cmd = new SqlCommand(queryString, con);
cmd.Parameters.Add(new SqlParameter("LOGIN_ID", txtLogin.Text));
cmd.Parameters.Add(new SqlParameter("LOGIN_PASSWORD", txtPass.Text));
sda.SelectCommand = cmd;
sda.Fill(ds, "LOGIN_TABLE");
//datatable dt
dt = ds.Tables["LOGIN_TABLE"];
//checking is datatable is empty
if (dt != null)
{
MessageBox.Show("Login Successed");
}
else
{
MessageBox.Show("Login Failed");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
ds.Clear();
dt.Clear();
}
헤이 뭔가 추가가 로그인과 암호를 저장하는 코드 –
을하고있다 데이터를 저장하는 것이 좋은 생각이 아닙니다. –
사용 유에게 적절한 가까이를 보장하고이 자원 – Steve