?
Solved

SqlDataSource doesn't seem to be using select parameter....

Posted on 2007-10-07
8
Medium Priority
?
579 Views
Last Modified: 2008-02-07
I have an SqlDataSource I am adding a Select Parameter to, the select statement works in the mysql console, if I had to make a guess, it seems like the parameter value isn't being passed correctly. I have googled, and I have tried every combo I can think of escape and operator characters. Any ideas are greatly appreciated.

        workString2 = workString2 + " and workqueuedescription like @search;";
        SqlDataSource2.SelectParameters.Add("search","%" + search + "%");
        SqlDataSource2.SelectParameters["search"].DefaultValue = "'%" + search + "%'";

        SqlDataSource2.SelectCommand = workString2;
        SqlDataSource2.DataBind();
0
Comment
Question by:addicktz
  • 5
  • 3
8 Comments
 
LVL 22

Expert Comment

by:JimBrandley
ID: 20030996
If you are using SQL Server, try changing your parameter name to "@search".

Jim
0
 
LVL 1

Author Comment

by:addicktz
ID: 20030999
I tried that, didn't work =[. Also, I am using MySQL
0
 
LVL 22

Expert Comment

by:JimBrandley
ID: 20031002
Sent that too soon. The parameter is named @search in your WHERE clause, so I expect the name needs to be the same when you build the parameter object.

Jim
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:JimBrandley
ID: 20031004
I have used Oracle and SQL server - will see if I can locate some documentation for MySQL.

Jim
0
 
LVL 1

Author Comment

by:addicktz
ID: 20031012
Thank you =]
0
 
LVL 22

Accepted Solution

by:
JimBrandley earned 2000 total points
ID: 20031015
If you are using ODBC, it doesn't take named parameters, in that case, change your where clause to:
workString2 = workString2 + " and workqueuedescription like ?;";

and the parameter should be good as it is. They are referenced by position instead of name.

Jim

0
 
LVL 1

Author Comment

by:addicktz
ID: 20031034
absolutely amazing, where did you find that information? Also, did it perhaps say, if I wanted to use the same parameter more than once? for instance,

workString2 = workString2 + " and (workqueuedescription like ? or workqueuename like ?;";

Thank you so much! =]

-Jeff
0
 
LVL 22

Expert Comment

by:JimBrandley
ID: 20031041
I searched this site for MySQL. I think you will have to add the parameter more than once if you want to use it more than once. AS:
workString2 = workString2 + " and (workqueuedescription like ? or workqueuename like ?;";

Then -
SqlDataSource2.SelectParameters.Add("search","%" + search1 + "%");
SqlDataSource2.SelectParameters.Add("search","%" + search2 + "%");

Glad it helped.

Jim
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month17 days, 3 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question