|
-
Dec 26th, 2008, 04:39 PM
#1
Thread Starter
Hyperactive Member
[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
-
Dec 26th, 2008, 10:58 PM
#2
Re: [3.0/LINQ] LINQ with Store Procedure with a Null Paramter
Could you try passing System.DBNull?
-
Dec 27th, 2008, 05:13 AM
#3
Thread Starter
Hyperactive Member
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.
-
Dec 29th, 2008, 07:35 AM
#4
Re: [3.0/LINQ] LINQ with Store Procedure with a Null Paramter
Try
Code:
Dim sp As New sqlParameter("@Something", dbNull)
-
Dec 29th, 2008, 05:56 PM
#5
Thread Starter
Hyperactive Member
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.
-
Dec 31st, 2008, 08:59 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|