2010. 3. 24. 12:16 PC Programming/C# .net
SqlCommand에서 Parameter 사용
String sSql;
SqlCommand sqlComm;
SqlDataReader sqlReader;
try
{
sSql = "SELECT PASSWORD FROM TB_USER WHERE USERID = @USERID ";
sqlComm = new SqlCommand(sSql, DBConnection.conn);
sqlComm.Parameters.Add(new SqlParameter("USERID", txtUserID.Text));
sqlReader = sqlComm.ExecuteReader();
if (sqlReader != null && sqlReader.HasRows)
{
sqlReader.Read();
if (sqlReader.GetString(0) == txtPassword.Text)
this.Close();
else
{
txtPassword.Text = "";
MessageBox.Show("비밀번호가 틀립니다.");
}
}
else
{
txtUserID.Text = "";
MessageBox.Show("존재하지 않는 아이디 입니다.");
}
sqlReader.Close();
}
catch (SqlException ex)
{
Program.angLog.WriteLog(String.Format("SQLException {0}", ex.Message));
}
catch (Exception ex)
{
Program.angLog.WriteLog(String.Format("Exception {0}", ex.Message));
}
'PC Programming > C# .net' 카테고리의 다른 글
Control에서 상속받아 User Control 만들때 Text Align (0) | 2012.03.19 |
---|---|
c# DOCK Property 설정 (0) | 2012.03.19 |
c# 에서 Debug메세지 뿌리기 (0) | 2011.08.08 |