Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 21st, 2007, 02:44 PM
Authorized User
 
Join Date: May 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default sending NULLs into a SQL Server PROC

I have a webpage that I have created in Visual Studio 2005/VB.net. I am trying to send values into a SQL Server Proc. In my proc, I have my input values in the PROC defined with default of NULL. How can I send a NULL from VB.net into my Proc? How can I make sure I'm sending NULL? I can't set anything to NULL in my VB code because the only valid(syntax wise) NULL is the DBNull.Value and that does not work on Strings. I end up passing spaces or something and my Proc doesn't work when I look for Null. The only way I can get it to work is to set the variable to something specific in my VB.net code and account for it in my Proc. For example, I set Age to 00 in my VB.net code as a default and send that to my Proc. In my proc I have to say if Age = '00' OR if it is a valid age I do something.

Thanks
LisaBB
 
Old June 21st, 2007, 03:36 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

When calling a stored procedure using a command object with parameters, you should be using DBNull.Value as you found. I'm not sure what error you could be getting. Even when you define a parameter with a specific DB data type, the .Value property is still of type 'Object' so you can still assign DBNull.Value to it.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
sending mail from sql server pady123 SQL Server 2005 0 October 17th, 2008 01:58 AM
problem sending values into SQL Server Proc lisabb ASP.NET 2.0 Basics 2 May 23rd, 2007 01:19 PM
MS Access .mdb calling SQL server 2000 stored proc fazzou Access 6 September 8th, 2006 11:32 AM
store proc use in report services of sql server shivani16 ADO.NET 3 June 22nd, 2004 11:17 AM
Ignoring nulls in stored proc 12th_Man SQL Language 4 June 17th, 2004 02:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.