Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Location
    Netherlands
    Posts
    98

    Question Unanswered: Problem with sp and uniqueidentifier

    Hi,

    I use this procedure to add a record to the db (SQL 2005)
    i constantly get this error:

    Conversion failed when converting from a character string to uniqueidentifier.

    This is the sp:

    Code:
    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    go
    
    ALTER PROC [dbo].[AddBootloader]
    
    		   @BootName  nvarchar(50),
               @Version  nvarchar(50),
               @CSD nvarchar(50),
    		   @CreatorID uniqueidentifier,
               @FilePath nvarchar(150),
               @FileSize nvarchar(150)
    
    
    AS
    INSERT INTO dbo.EB_Bootloaders
    
    		   ([Bootname]
               ,[Version]
               ,[CSD]
               ,[FilePath]
               ,[FileSize]
               ,[CreatorID])
    		   
    
    VALUES
    
    (
    		   @BootName,
               @Version,
               @CSD,
               @CreatorID,
    		   @FilePath,
    		   @FileSize)

    And this is the table:

    Code:
    USE [Ebdata]
    GO
    /****** Object:  Table [dbo].[EB_Bootloaders]    Script Date: 07/12/2006 10:06:42 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[EB_Bootloaders](
    	[ID] [bigint] IDENTITY(1,3) NOT NULL,
    	[BootName] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL,
    	[Version] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL,
    	[CSD] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL,
    	[FilePath] [nvarchar](150) COLLATE Latin1_General_CI_AS NULL,
    	[FileSize] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL,
    	[CreateDate] [datetime] NULL CONSTRAINT [DF_EB_Bootloaders_CreateDate]  DEFAULT (getdate()),
    	[CreatorID] [uniqueidentifier] NOT NULL,
    	[UpdateDate] [datetime] NULL,
    	[UpdateUser] [uniqueidentifier] NULL,
     CONSTRAINT [PK_EB_Bootloaders_1] PRIMARY KEY CLUSTERED 
    (
    	[ID] ASC
    )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
    ) ON [PRIMARY]
    
    GO
    USE [Ebdata]
    GO
    ALTER TABLE [dbo].[EB_Bootloaders]  WITH NOCHECK ADD  CONSTRAINT [FK_EB_Bootloaders_aspnet_Users] FOREIGN KEY([CreatorID])
    REFERENCES [dbo].[aspnet_Users] ([UserId])
    NOT FOR REPLICATION 
    GO
    ALTER TABLE [dbo].[EB_Bootloaders]  WITH NOCHECK ADD  CONSTRAINT [FK_EB_Bootloaders_aspnet_Users1] FOREIGN KEY([UpdateUser])
    REFERENCES [dbo].[aspnet_Users] ([UserId])
    NOT FOR REPLICATION
    The funny thing is that i copied the sp code from another which runs perfect,
    I insert a Guid from an asp.net page.

    Hope someone can help me here because im am stucked!

    Cheers Wimmo

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi Wimmo

    Aren't your VALUES in your insert statement in the wrong order (@CreatorID should be last not fourth)?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Jul 2006
    Posts
    1

    column order was different

    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    go

    ALTER PROC [dbo].[AddBootloader]

    @BootName nvarchar(50),
    @Version nvarchar(50),
    @CSD nvarchar(50),
    @CreatorID uniqueidentifier,
    @FilePath nvarchar(150),
    @FileSize nvarchar(150)


    AS
    INSERT INTO dbo.EB_Bootloaders

    ([Bootname]
    ,[Version]
    ,[CSD]
    ,[CreatorID]
    ,[FilePath]
    ,[FileSize]
    )


    VALUES

    (
    @BootName,
    @Version,
    @CSD,
    @CreatorID,
    @FilePath,
    @FileSize)

  4. #4
    Join Date
    Oct 2003
    Location
    Netherlands
    Posts
    98
    Euh thanx, think i was sleeping!
    Glad some people are awake!
    Thanx for helping me!

    cheers Wim

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •