Results 1 to 6 of 6

Thread: [3.0/LINQ] LINQ with Store Procedure with a Null Paramter

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    484

    [3.0/LINQ] LINQ with Store Procedure with a Null Paramter

    Hi There,

    I want to send a null value to the store procedure in C#, but I just can't get that to work, anybody have some idea.

    The field type is Guid, so I used the following code.

    Code:
    DataContext.StoreProc null - Gave me error.
    DataContext.StoreProc SqlGuid.Null.Value - Gave me error.
    DataContext.StoreProc SqlGuid.Parse("").Value - Gave me error
    DataContext.StoreProc SqlGuid.Parse(null).Value - Gave me error
    So how do I send a null to a store proceudre?

    Any idea?

    Regards

    PlayKid

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: [3.0/LINQ] LINQ with Store Procedure with a Null Paramter

    Could you try passing System.DBNull?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    484

    Re: [3.0/LINQ] LINQ with Store Procedure with a Null Paramter

    Nop...still give an error, something like unable to convert System.DBNull to System.Guid.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [3.0/LINQ] LINQ with Store Procedure with a Null Paramter

    Try
    Code:
    Dim sp As New sqlParameter("@Something", dbNull)

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    484

    Re: [3.0/LINQ] LINQ with Store Procedure with a Null Paramter

    Doesn't like that neither, same error as above, unable to convert SQLParameter to SQLGuid.
    But I have decided to use normal ADO.Net instead of going thru LINQ, although I know LINQ is based on ADO.Net, but that null thing just not work for me on LINQ.

    Thanks anyway.

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [3.0/LINQ] LINQ with Store Procedure with a Null Paramter

    Do you have access to the DataContext class itself? You should be able to change the parameters to nullable types, surely...

Posting Permissions

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



Click Here to Expand Forum to Full Width