Hello guys I have got this code Which I would like it to do simple thing:
SELECT * FROM klisluz WHERE IDzajsluz= id
SELECT * FROM klisluz WHERE subkey = vyberradek
But this simple thing makes this problém:
At the moment its showing me rows where subkey isnt equal to vyberradek
. How is that possible?
vyberradek
is INT
ID which i transfer via string
for (int i = 0; i < dtg_ksluzby.Rows.Count;i++)
{
var row = dtg_ksluzby.Rows[i];
int id = (int)row.Cells["ID"].Value;
using (var novyprikaz3 = new SqlCommand("SELECT * from klisluz WHERE subkey= '" + vyberradek + "' AND IDzajsluz='" + id + "'", spojeni))
{
spojeni.Open();
SqlDataReader precti3 = novyprikaz3.ExecuteReader();
if (precti3.HasRows)
{
row.Cells[4].Value = true;
}
spojeni.Close();
}
Would somebody help me solve this thing out?
Thanks in advance.
I posted Picture which shows that it selects rows which it shouldnt.