for (int i = 0; i < final_query.Length; i++)
{
con.Open();
SqlCommand cmd=new SqlCommand("SELECT * fROM TableFFF WHERE Data="+final_query[i]);
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
string PatientName = (string)rdr[" Data "];
}
}
I got that error
ExecuteReader: Connection property has not been initialized.
on this line
SqlDataReader rdr = cmd.ExecuteReader();
How can i fix it?
You need to pass the Connection to the SqlCommand
But there are other errors:
Use and reuse Parameters, not string concatenation
And it is still not clear what you are supposing to do with the PatientName after the first round