First off, you never close the connection, which is bad - use a
using
block to ensure that connections and commands are closed and disposed when you are finished with them:
using (SqlConnection con = new SqlConnection(strConnect))
{
con.Open();
using (SqlCommand cmd = new SqlCommand("SELECT Age, Description FROM myTable WHERE ID = @ID", con))
{
cmd.Parameters.AddWithValue("@ID", myTextBox.Text);
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
int age = (int) reader["Age"];
string desc = (string) reader["Description"];
Console.WriteLine($"{age}\n{desc}");
}
}
}
}
(It's the same for OleDb objects as SqlServer objects).
Second, why are you returning an SQL query? Wouldn't it make more sense to return the result of the ExecuteNonQuery call? That way, the calling function can check if it deleted any rows ...
Third, that code looks like it might work - though I'd worry about SQL Injection