Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Contains statement in sqldatasource????

Author  Topic 

manared
Starting Member

10 Posts

Posted - 2007-11-05 : 09:50:23
I actually have a SQL question:

I have a web app and I want to have just a sqldatasource that calls the SQL server database. (I may not be able to do this though, not sure).
I have a label that will have a full name in it during the page load event. After the name is put into the label, I want to use that for the sql statement. But, I want something like a contains statement.

For example, if the lblfullname.text = "Joe Smith" then the field I'm comparing it to in the database is "Amanda Doe,Joe Smith,Jack Coart"
I want to grab this whole row in the database table because "Joe Smith" is part of the field in the database. I don't know if there's a contains or like statement or something that I can use for this? Before I could use "where assigned_to = '" & lblfullname.text & "'" when I only had one name in the database. But now I have multiple names in the table.

So overall, I have a grid I want to populate with all the tasks assigned to a specific person. But one task could have several people assigned to it, yet when those people view the web application, I want the grid to show all the tasks that are assigned to them, including the ones that have multiple people.

I'm sorry if this is confusing. Not sure how to explain it. If more info or code is needed, please let me know. Thank you much!!!

JBelthoff
Posting Yak Master

173 Posts

Posted - 2007-11-09 : 20:58:17
If I understand correctly, in your database you have 1 row per task. And each task may have multiple people assigned to it? Like this:


Task Names
1 John John, John Jay, John Blue
2 Jim John, John Blue, Jim Jim, Paul Revere
3 John Jay, Jim Jim, John Blue


If that is the case then

Select Task
From Table
Where Names Like '%John Jay%'

Will bring back 2 records with Task 1 and 3.

Is that right? I'm not sure if that is the best way to store your data.



JBelthoff
• Hosts Station is a Professional Asp Hosting Provider
› As far as myself... I do this for fun!
Go to Top of Page
   

- Advertisement -