none
How do I display a list of results based on a query?

    Question

  • Hello,

    I am querying a SQL2008 database using cshtml from webmatrix (basically HTML)

    I need to get a list of stock codes that have a certain classification, and are out of stock.

    The table is STOCK_ITEMS and the columns to reference are STOCKCODE (PK, varchar(23), not null), STOCK_CLASSIFICATION (int, not null), TOTALSTOCK (float, not null).

    I want to ask for all STOCKCODE with a certain STOCK_CLASSIFICATION where TOTALSTOCK <1. I declare thius in the html as a var called @nilstock.

    I tried `select * from dbo.STOCK_ITEMS where STOCK_CLASSIFICATION = 190 and TOTALSTOCK  <1` - only gave me the first part number :(

    I tried select STOCKCODE, TOTALSTOCK from dbo.STOCK_ITEMS where STOCK_CLASSIFICATION = 190 and TOTALSTOCK <1 - same result

    Now, if I run the above query in SQL directly, it works fine and gives me a list.

    I am using the html command @nilstock.ToString() to display the result: maybe this is where I get my error?

    Any help gratefully accepted :)

    Wednesday, December 11, 2013 7:24 PM