Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 19th, 2005, 11:10 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

You cannot use @Set_name as a variable name. That is SQL Server syntax. You have to declare a variable using C# syntax.

 
Old October 20th, 2005, 08:34 AM
Authorized User
 
Join Date: Oct 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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>

 
Old October 20th, 2005, 09:09 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Just for a test remove the @ from the variable and try it that way.

 
Old October 20th, 2005, 09:32 AM
Authorized User
 
Join Date: Oct 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had tried taking out the @ once before, but I tried again since I am getting desperate. Still nothing.

 
Old October 20th, 2005, 12:30 PM
Authorized User
 
Join Date: Oct 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you everyone for your help I finally figured it out.

this code needed to be added to make it a parameter.

<code>
System.Data.IDataParameter dbParam_Set_Name = new System.Data.SqlClient.SqlParameter();
dbParam_Set_Name.ParameterName = "@Set_Name";
dbParam_Set_Name.Value = Request.QueryString["@Set_Name"];
dbParam_Set_Name.DbType = System.Data.DbType.String;
dbCommand.Parameters.Add(dbParam_Set_Name);
</code>

Thanks again for all your help.







Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with URL rewrite mlcy ASP.NET 2.0 Professional 3 June 21st, 2007 06:05 PM
URL Redirection Problem rch123 Need help with your homework? 0 June 18th, 2007 11:20 AM
Navigation url problem? Hannibal ASP.NET 2.0 Basics 1 December 14th, 2006 05:23 AM
URL encode problem mat41 Classic ASP Professional 3 August 23rd, 2006 07:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.