Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I have an asp.net web site with the Microsoft Access database. I have a product table, which contain the multiple categories with the coma seprated from the category table. I need to fetch the product information with all the respective category. I have created the product.xsd with the product adapter. I have used the GetCategory(string categoryIds) function, where I pass multiple categories. The problem is that, when I pass single category in the function its return the category information, however when I pass multiple categories then it does not return any record.
Here is the code
C#
 private string GetCategories(string categories)
{
    categories = "'" + "C0004" + "','" + "C0005" + "'";
    string categoryNames =  string.Empty;
        
    CategoryMasterTableAdapter obCategoryMasterTableAdapter = newCategoryMasterTableAdapter();
    CategoryMasterDataTable categoryTable = newCategoryMasterDataTable();
    categoryTable = obCategoryMasterTableAdapter.GetCategories(categories);
    for (int iCount = 0; iCount < categoryTable.Rows.Count; iCount++)
    {
        CategoryMasterRow drow = categoryTable[iCount];
        if (!String.IsNullOrEmpty(categoryNames))
        {
            categoryNames = "," + drow.CatDesc ;
        }
        else
        {
            categoryNames = drow.CatDesc;
        }
    }
    return categoryNames; 
}



Table Adapter query is
SELECT BookGroup, CatCode, CatDesc, CatTitle, ChildCatCode, ParentCatCode, UpdateStatus FROM CategoryMaster WHERE (CatCode IN (?))


can anyone tell me what is the problem or how to pass the multiple categoryids in a single parameter

[Modified: changed inline code tag to pre tag]
Posted
Updated 19-Apr-10 7:36am
v2

1 solution

Pankaj Saha wrote:
WHERE (CatCode IN (?))


Simply put the list of CatCodes where you have the ?. For example:

Pankaj Saha wrote:
WHERE CatCode IN ('C0004', 'C0005')


See http://www.w3schools.com/sql/sql_in.asp[^] for an example.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900