Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 24th, 2007, 03:43 AM
Registered User
 
Join Date: Dec 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with StoredProcedure

Hi...

Am working with asp.net with vb for a MusicProject..

In this I have playlist for particular User..ie User Selects Some Songs and clicks on AddToMyPlayList Button....

Here He can insert those songs into a new playlist or update the earlier..

the StroedProcedure is as follws: 'N' means NewPlayList and 'E' means Existing

 ************************************************** *************************************

CREATE PROCEDURE MUSIC_ADD_PLAYLIST
(
@PLAYLIST_NAME VARCHAR(255),
@USER_ID VARCHAR(255),
@ItemList NVARCHAR(4000),
@delimiter CHAR(1),
@FOLDERNAME VARCHAR(255) ,
@PLAYLISTTYPE CHAR(1)
)
AS

SET NOCOUNT ON

  DECLARE @IDENT INT


IF @PLAYLISTTYPE = 'N'

BEGIN

  INSERT INTO MUSIC_PLAYLIST
  (
   MUSIC_PLAYLIST_NAME,
   MUSIC_PLAYLIST_USER
  )

  VALUES

  (
   @PLAYLIST_NAME,
   @USER_ID
  )


  SELECT @IDENT=@@IDENTITY FROM MUSIC_PLAYLIST

END

 IF @PLAYLISTTYPE='E'

 BEGIN

 SELECT @IDENT=MUSIC_PLAYLIST_ID FROM MUSIC_PLAYLIST WHERE MUSIC_PLAYLIST_USER=@USER_ID AND MUSIC_PLAYLIST_NAME=@PLAYLIST_NAME

 END


  DECLARE @tempItemList NVARCHAR(4000)
      SET @tempItemList = @ItemList

      DECLARE @i INT
      DECLARE @Item NVARCHAR(4000)

      SET @tempItemList = REPLACE (@tempItemList, ' ', '')
      SET @i = CHARINDEX(@delimiter, @tempItemList)

      WHILE (LEN(@tempItemList) > 0)
      BEGIN
          IF @i = 0
              SET @Item = @tempItemList
          ELSE
              SET @Item = LEFT(@tempItemList, @i - 1)
         -- INSERT INTO @IDTable(Item) VALUES(@Item)



   INSERT INTO MUSIC_SONGSLIST
    (Music_PlayList_Id,Music_SongName,Music_Song_Locat ion)
    VALUES
    (@IDENT,@ITEM,@FOLDERNAME+'\'+@ITEM)


          IF @i = 0
              SET @tempItemList = ''
          ELSE
              SET @tempItemList = RIGHT(@tempItemList, LEN(@tempItemList) - @i)
          SET @i = CHARINDEX(@delimiter, @tempItemList)

  END

GO

************************************************** *************************************

Here the problem is am not getting the exact result means if i add 6 songs to a playlist it is adding only 4 songs to that particular playlist..

Please help me out

Thanks in Advance,
Madhavi



 
Old December 26th, 2007, 12:41 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

What happens when you run this code in Query Analyzer? Does it work correctly?






Similar Threads
Thread Thread Starter Forum Replies Last Post
StoredProcedure For Adding PlayList tmadhavi SQL Server 2000 0 December 20th, 2007 08:31 AM
SQL Server StoredProcedure Parameter pass erictamlam C# 2005 3 March 27th, 2007 01:31 AM
Help with using a StoredProcedure to write to SQL garryg ASP.NET 1.0 and 1.1 Basics 1 February 17th, 2006 03:42 PM
Calling a Storedprocedure from ASP arnniema Classic ASP Basics 1 September 15th, 2005 07:49 AM
StoredProcedure NiNe ADO.NET 1 March 1st, 2004 07:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.