Showing posts with label toa. Show all posts
Showing posts with label toa. Show all posts

Sunday, February 19, 2012

asp:sqldatasource - sum and contains

I have an asp:sqldatasource which is bound to a gridview

In addition to this I would like it to
a) see if there is a specif row/ item in it (ie item_id = 10 for any of the rows it has received) as I conditionally want to show another item outside of the gridview subject to if it is in the gridview or not

b) show the sum of all the values within a certain column of returned rows

Many thanks

not quite sure I understand your question a) but I for question b)

select sum(quantity) from table where id = 1

will return the sum of the quantity which id column equal to 1

Monday, February 13, 2012

ASP.NET SQL CONTAINS statement

I have an SQL db that I need to be able to search and display. I haveabout seven different columns and would like results to be returned toa datagrid based upon the search criteria entered by the user.
How do I construct a SELECT statement such as below using the ASP.NET 1.1+?
SELECT * FROM db.table WHERE CONTAINS ("searchable term")
I can get a column searched and return the results already, but if Imodify to search all columns and use the CONTAINS it will fail. Isthere a way to do this easily?
Thanks,
TRKneller

Your query is failing because you are using CONTAINS Microsoft Proprietry FULL TEXT search predicate when you need to use LIKE which is ANSI SQL used to search table column based data. Full Text is used for Text and NText data but it is an add on to SQL Server dependent on Microsoft Search Service and the Catalog must be populated to get search results. SQL Server creates an Arithmetic Pointer to Text and NText data in your file system. Run a search for LIKE and FULL Text in the BOL(books online). Hope this helps.