{"Fetch Error:Conversion failed when converting the varchar value 'Data Base' to data type int."}
What I have tried:
private DataTable GetData()
{
DataTable dt = new DataTable();
SqlConnection connection = new SqlConnection("Data Source=.;Initial Catalog=Quiz_system;Integrated Security=True");
try
{
connection.Open();
SqlCommand sqlCmd = new SqlCommand("Select question_no,question,op1,op2,op3,op4,correct_ans From tbl_question_bank where course_name='" + lblcorrect.Text.ToString() + "' and quiz_id='"+lblqid.Text+"'", connection);
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
sqlDa.Fill(dt);
}
catch (System.Data.SqlClient.SqlException ex)
{
string msg = "Fetch Error:";
msg += ex.Message;
throw new Exception(msg);
}
finally
{
connection.Close();
}
return dt;
}