Stored Proc question

  • I have 2 tables k_hotel_description and

    k_seas_avail

    When i run the store proc below

    select k_seas_avail.CatID,k_seas_avail.DescID,seas_id,season,twin,triple,single,hotels,rating,location

    from k_seas_avail

    inner join k_hotel_description  on k_seas_avail.DescID = k_hotel_description.DescID

    --inner join k_seas_avail on k_seas_avail.CatId = k_hotel_description.CatID

    where k_hotel_description.DescID = 2

    I get a good resultset but the problem is 'm databinding using a datalist.After binding i don't get the fields k_seas_avail.DescID,seas_id,season,twin set correcty i only the values for Descid = 2 for both of the  columns in my datalist whereas descid 2 has only one row in the "k_seas_avail table"

    How can i query it to return the right resultset for the correct Descid's

    CREATE TABLE [k_seas_avail] (

     [seas_id] [int] IDENTITY (1, 1) NOT NULL ,

     [CatID] [int] NOT NULL ,

     [Season] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

     [Twin] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

     [Triple] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

     [Single] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

     [DescID] [int] NULL ,

     CONSTRAINT [PK_seas_avail] PRIMARY KEY  CLUSTERED

     (

      [seas_id]

    &nbsp  ON [PRIMARY]

    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

    GO

     

    CREATE TABLE [k_hotel_description] (

     [DescID] [int] IDENTITY (1, 1) NOT NULL ,

     [CatID] [int] NOT NULL ,

     [hotels] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

     [location] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

     [facilities] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

     [image] [image] NULL ,

     [rating] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

     [rate_color] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

     CONSTRAINT [PK_Offers] PRIMARY KEY  CLUSTERED

     (

      [DescID]

    &nbsp  ON [PRIMARY]

    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

    GO

  • Can you elaborate

    I get a good resultset but the problem is 'm databinding using a datalist.After binding i don't get the fields k_seas_avail.DescID,seas_id,season,twin set correcty i only the values for Descid = 2 for both of the  columns in my datalist whereas descid 2 has only one row in the "k_seas_avail table"

    with some sample data.

    As far my deciphering goes:

    Your stored procedure gives the good result (only 1 record for descid 2 ) but in your datalist it appears twice???

  • Thx Jo Pattyn for the reply.

    Thats exactly my problem.

    The resultset that return is good.

    But the problem is if i databind it appears twice that means for descid 1 and 2.

    Whilst i want it to appear only for one row for example where descid=1

    Hope you got me now

    Thanks

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply