I’m using this code and while I run my code I got an error.
Incorrect Syntax near where clause.
This is my C# code:
SqlConnection con = new SqlConnection("Data Source=ANURAG-PC;Initial Catalog=dbPortal;Persist Security Info=True;User ID=yyyy;Password=xxxxx");
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{
string s = Request.QueryString["cat"];
string s1 = Request.QueryString["sub"];
SqlCommand cmd = new SqlCommand("Select * from Architect where where SubCategory1 = @sub1",con);
cmd.Parameters.AddWithValue("@sub1", s1);
con.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
DataTable dat = new DataTable("tab");
dat.Load(reader);
DataGrid1.DataSource = dat;
DataGrid1.DataBind();
}
}
}
Whats wrong in it?
Look at the query – you have
where wherethere. There should only be onewhere:Should be: