Quote:
quote:Originally posted by jbenson001
You cannot use @Set_name as a variable name. That is SQL Server syntax. You have to declare a variable using C# syntax.
|
I do have @Set_Name delcared as a c# variable. As a test I hardcoded a set name into the sql query (to get rid of the error) and just print that variable out to an asp:label it works just fine.
This code works perfect. The only problem is that I can only print @Set_Name and can't use it in the query.
<code>
string @Set_Name;
string ConnectionString = "server=edev03;database=on_track;user id=johnrose; password=jrontrack";
string SelectCommand =
"SELECT smile_data.qsect_key, smile_data.ques_id, smile_data.esetq_id, smile_data.Ques_Order, smile_data.Q_Section, smile_data.Q_Text
FROM Smile_Data
WHERE Smile_Data.Set_Name='smile'
ORDER BY Smile_Data.Set_Name, Smile_Data.Sect_Order, Smile_Data.Ques_Order";
void Page_Load(object sender, EventArgs e) {
if (!Page.IsPostBack) {
@Set_Name = Request.QueryString["Set_Name"];
lblsetName.Text = @Set_Name;
BindGrid();
}
}
</code>