Showing posts with label update. Show all posts
Showing posts with label update. Show all posts

Friday, 28 September 2012

WCF Service Reference Error

I tried updating my WCF service references in my web project and received this strange error:

Error        265          Missing partial modifier on declaration of type 'xyz'; another partial declaration of this type exists   Reference.cs

This mean't I had a class in the service or the web projects that are named the same but are not set as partials. The problem was in the service project the complex object in my EF 4 entities did not generate a partial class when referenced in the References.cs file of the web project.

I had to configure the service reference to reuse the System assembly, then update my reference again and everything worked - strange error :(

This post helped me a bit http://stackoverflow.com/questions/8542514/wcf-reference-cs-suddenly-not-including-classes

Thursday, 3 December 2009

Example: Use a cursor to fetch records and update individual records

-- Only add the new column if it doesn't exist.
IF NOT EXISTS (
SELECT Object_ID FROM sys.columns
WHERE Name = N'DateTimeStamp' and Object_ID = Object_ID(N'dbo.tblLog')
)
BEGIN
-- Add a new column to store a proper datetime value.
ALTER TABLE dbo.tblLog
ADD DateTimeStamp DATETIME

-- Get the char dates for conversion into proper datetime objects.
DECLARE DateList CURSOR FOR
SELECT date, hour FROM dbo.tblLog FOR UPDATE OF DateTimeStamp

-- Loop variables
DECLARE @Date CHAR(20)
DECLARE @Hour INT

-- Loop thorugh and update the new column with the current row date string as a proper datetime.
OPEN DateList
FETCH NEXT FROM DateList
INTO @Date, @Hour
WHILE @@FETCH_STATUS = 0
BEGIN
UPDATE dbo.tblLog
SET DateTimeStamp = CONVERT(DATETIME, SUBSTRING(@Date, 7, 4) +
'-' + SUBSTRING(@Date, 4, 2) + '-' + SUBSTRING(@Date, 0, 3) +
' ' + CONVERT (CHAR(2), @Hour) + ':00:00')
WHERE CURRENT OF DateList

FETCH NEXT FROM DateList INTO @Date, @Hour
END

-- Clean up.
CLOSE DateList
DEALLOCATE DateList
END

SELECT * FROM dbo.tblLog