I am using this sql query in c#
select t.testname,t.totalque,r.testdate,r.score
from test t, result r
where t.testid=r.testid
and r.login='vsdep980'
but it shows an error that is
invalid column name 'vsdep980'
now here vsdep980 is the value which is stored in the column login but why it shows this type of error.
now my code is
SqlCommand cmd = new SqlCommand("select t.testname,t.totalque,r.testdate,r.score from test t, result r where t.testid=r.testid and r.login=vsdep980", con);
con.Open();
int c = Convert.ToInt32(cmd.ExecuteScalar());
con.Close();
if (c > 0)
{
Response.Write("<br><br><h1 class='head1'> You have not given any quiz</h1>");
Response.End();
}
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adp.Fill(ds);
DataTable dt = ds.Tables[0];
DataRow dr = null;
Response.Write("<table border='1' align='center'><tr class='style2'><td width='300'>Test Name </td><td> Total<br> Question </td><td> Date </td><td> Score </td></tr>");
foreach (DataRow dr1 in dt.Rows)
{
dr = dr1;
Response.Write("<tr class='style8'><td> "+dr[0]+" </td><td align='center'> "+dr[1]+" </td><td align='center'> "+dr[2]+" </td><td align='center'>"+dr[3]+" </td></tr>");
}
Response.Write("</table>");
image of error msg
Please help me.
Thanks.
