Friday, March 23, 2012

How to create categories tree with subcategories ?

Hi, I Have 2 tables. First name of this tables is news_categories with one record: News. Strucutre this table ID and name_categories Second name of this tables is news_subkategorie with two records : With country and with world. Strucutre ID_Subcategories and name_subcategories I will receve effects:

News

--With country

--With world

How i write in Select Command ?

SELECT [ID_subcategries], [Name_subcategories], [ID] FROM [db_subcategories], [db_categories] WHERE (??)

How do you connect categories and subcategories? Does db_subcategories have ID which says to which category that subcategory belongs?

If that is true, than:

SELECT db_categories.ID, [ID_subcategries], [Name_subcategories]FROM [db_subcategories], [db_categories]WHERE db_categories.ID = db_subcategories.IDOrder By 1Asc, 2Asc
|||

Hi,

this is my conncetion in web.config:

<

connectionStrings>

<

addname="ConnectionString"connectionString="Data Source=FS_AMILO_2065;Initial Catalog=sklep.mdf;Integrated Security=True"providerName="System.Data.SqlClient" />

</

connectionStrings>

I have in categories.aspx GridView I link to subcategories.asp

subcategories?id={0}

|||

You can use modification of above query to return all subcategories for given ID:

SELECT [ID_subcategries], [Name_subcategories]FROM [db_subcategories]WHERE db_subcategories.ID = @.catIDOrder By 1Asc, 2Asc

where you use @.catID to store supplied ID

|||

ID is a ID from categories ?

I mustMust declare the scalar variable "@.ID".

So i go to Pramters and ID is a QuertyString and ??

sql

No comments:

Post a Comment