TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mike Simo
NA
17
12.4k
Must declare the scalar variable
Jul 1 2014 11:37 PM
Hi
In my below code i am getting a blue line under the session 'SearchValue' in the line:
DAsearch.SelectCommand.Parameters.AddWithValue("@Wtags", SearchValue); . and the error message is:
Must declare the scalar variable "@Wtags".
var location = Convert.ToString(Session["location"]);
var cat = Convert.ToString(Session["SearchValue"]);
if (Session["location"] != null)
{
using (SqlConnection srchsql = new SqlConnection(sc))
{
srchsql.Open();
SqlDataAdapter DAsearch = new SqlDataAdapter("SELECT [AdsID],[AdsTit], SUBSTRING([AdsDesc],1,155) as AdsDesc, [Section], [Category], [Wtags], [Country], [State], [City] FROM [ads] WHERE (([Country] = @Country) AND ([Wtags] = @Wtags))", sc);
DataSet DSsrchP = new DataSet();
DAsearch.SelectCommand.Parameters.AddWithValue("@Country", location);
DAsearch.SelectCommand.Parameters.AddWithValue("@Wtags", SearchValue);
DAsearch.Fill(DSsrchP);
resultshowlistview.DataSource = DSsrchP.Tables[0];
resultshowlistview.DataBind();
}
}
else
{
}
Reply
Answers (
2
)
cursors
Show image from table