Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 2nd, 2006, 04:09 AM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 11

hi
in cahpter 11 in the book Beginning Visual Basic 2005
i have to creat new stored produce

and this is his code


Code:
CREATE  PROCEDURE usp_InsertTimeSheet
(
   @TimeSheetID      UNIQUEIDENTIFIER,
   @UserID           UNIQUEIDENTIFIER,
   @WeekEndingDate   DATETIME
)
AS

DECLARE @GroupID UNIQUEIDENTIFIER,
        @ProjectID UNIQUEIDENTIFIER,
        @TimeSheetDate DATETIME,
        @i TINYINT

-- Get the GroupID that the user belongs to
SELECT @GroupID = GroupID FROM Users WHERE UserID = @UserID

DECLARE Project_Cursor CURSOR FOR SELECT ProjectID 
   FROM GroupProjects WHERE GroupID = @GroupID

BEGIN TRANSACTION
   BEGIN TRY
      -- Insert the time sheet
      INSERT INTO TimeSheets
         (TimeSheetID, UserID, WeekEndingDate, Submitted, ApprovalDate,
         ManagerID, LastUpdateDate)
         VALUES(@TimeSheetID, @UserID, @WeekEndingDate, 0, NULL,
         NULL, GETDATE())
   END TRY
   BEGIN CATCH
      ROLLBACK TRANSACTION
      RAISERROR('Insert into TimeSheets failed.',18,1)
      RETURN
   END CATCH

   -- Set the initial time sheet date to the beginning of the week
   SET @TimeSheetDate = @WeekEndingDate - 4

   -- Set up a loop to insert time sheet items for 5 days
   SET @i = 1
   WHILE (@i < 6)

      BEGIN
      -- Open the cursor
      OPEN Project_Cursor

      -- Get the first row of data from the cursor into our variable
      FETCH NEXT FROM Project_Cursor INTO @ProjectID

      WHILE @@FETCH_STATUS = 0
         BEGIN
         BEGIN TRY
            -- Insert the time sheet item
            INSERT INTO TimeSheetItems
            (TimeSheetItemID, TimeSheetID, ProjectID, Hours, TimeSheetDate)
               VALUES(NEWID(), @TimeSheetID, @ProjectID, 0, @TimeSheetDate)
         END TRY
         BEGIN CATCH
            ROLLBACK TRANSACTION
            RAISERROR('Insert into TimeSheetItems failed.',18,1)
            RETURN
         END CATCH
         -- Get the next row of data from the cursor into our variable
         FETCH NEXT FROM Project_Cursor INTO @ProjectID
         END

      CLOSE Project_Cursor

      -- Increment the date by one day
      SET @TimeSheetDate = @TimeSheetDate + 1
      -- Increment the loop counter by one
      SET @i = @i + 1
      END

-- Deallocate cursor
DEALLOCATE Project_Cursor

-- Commit all inserts
COMMIT TRANSACTION
and i cant there is error
and this the messege

Msg 170, Level 15, State 1, Procedure usp_InsertTimeSheet, Line 21
Line 21: Incorrect syntax near 'TRY'.
Msg 156, Level 15, State 1, Procedure usp_InsertTimeSheet, Line 28
Incorrect syntax near the keyword 'END'.
Msg 156, Level 15, State 1, Procedure usp_InsertTimeSheet, Line 33
Incorrect syntax near the keyword 'END'.
Msg 170, Level 15, State 1, Procedure usp_InsertTimeSheet, Line 51
Line 51: Incorrect syntax near 'TRY'.
Msg 170, Level 15, State 1, Procedure usp_InsertTimeSheet, Line 56
Line 56: Incorrect syntax near 'TRY'.
Msg 170, Level 15, State 1, Procedure usp_InsertTimeSheet, Line 61
Line 61: Incorrect syntax near 'CATCH'.
Msg 156, Level 15, State 1, Procedure usp_InsertTimeSheet, Line 64
Incorrect syntax near the keyword 'END'.
Msg 156, Level 15, State 1, Procedure usp_InsertTimeSheet, Line 72
Incorrect syntax near the keyword 'END'.

can you help me and told me what is the error and how to fix it
i am using sql server 2005 which comes with VS.2005
thank you


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
chapter 11 figure 11-7 relative positioning pelopito BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 2 November 29th, 2007 05:11 AM
Chapter 11 mhanson BOOK: Professional VB 2005 ISBN: 0-7645-7536-8 0 July 10th, 2007 08:40 PM
Chapter 11: kiley-s BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 10 March 8th, 2007 07:19 PM
Chapter 11 kappa3 Wrox Book Feedback 0 October 8th, 2003 11:21 AM



All times are GMT -4. The time now is 05:14 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.