You can follow this process
using (SqlCommand command = new SqlCommand("Select student.sname,admission.sroll,admission.scourse,admission.semester from admission,student where admission.asid=@Variable and admission.asid=student.sid", connection))
{
command.Parameters.Add(new SqlParameter("Variable", txtVariable.Text.Trim()));
SqlDataReader reader = command.ExecuteReader();
DataTable dataTable = new DataTable();
dataTable.Load(reader);
}