I'm implementing the function of getting the value of row 3 when I press the button, but I can't read the 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 ("Can't Read");
}
suzyread.Close();
conn.Close();
}
This is when the if statement is cleared and executed.
There seems to be no problem with grammar.
If you have any other problems, I can't clearly understand what the problem is based on your questions.
There are things you need to check in order to answer correctly.
I think you should check if the connection is made.
If the connection is successful, you should check to see if the query is feasible and if the results are as good as expected.
If the above things are executed well, I think we should check the results of the query execution.
And the part that you captured and uploaded...
The original code executes suzyread.Read() in the if statement.
This is a problem caused by not reading the data because I deleted the if statement.
928 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
579 Understanding How to Configure Google API Key
575 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
624 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.