버튼을 누르면 rows의 3번째 열의 값을 가져오는 기능을 구현중인데 , db를 읽어오지못하네요..
private void btnSearch_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=YONGCHEOL;Initial Catalog=ADO;Integrated Security=True");```
conn.Open();
string suzy = "SELECT * FROM rankTBL where NAME='" + txtName+ "' AND CLASS='" + ClassNum+ "'";
SqlCommand cmd = new SqlCommand(suzy, conn);
SqlDataReader suzyread = cmd.ExecuteReader();
if (suzyread.Read())
{
kor = suzyread.GetInt16(3);
lbEng.Text = kor.ToString();
}
else
{
MessageBox.Show("read못함");
}
suzyread.Close();
conn.Close();
}
if문을 지우고 실행했을때입니다.