Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 27th, 2006, 03:58 AM
Friend of Wrox
 
Join Date: Jun 2004
Location: Alhambra, ca, USA.
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default String="" convert to DBNull

Hello
If UserName="" then I want to pass to SQL Server DBNull rather than "". In SQL Stored Procedure it looks for where @UserName is null. In SQL Stored Procedure it doesn't work the same when I look for @UserName="".

SELECT User.UserID,
        User.UserName,
        User.Disabled,
        User.Deleted,
        User.UserLoginCount,
        User.ViewResume,
        User.ViewSource

FROM User INNER JOIN Email ON User.UserID = Email.UserID
WHERE (User.Deleted = @deleted)
    AND (@UserName is null OR User.UserName LIKE @UserName + '%')

How can I set UserName object to be DBNull and not "". VB.NET code is preferred. Thank you.

  #2 (permalink)  
Old February 28th, 2006, 01:28 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

If UserName = "" Then
   UserName = System.Convert.DBNull
End If

Jim


 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert to string prafullaborade XML 7 May 29th, 2008 02:59 PM
Conversion from type 'DBNull' to type 'String' is GailCG ASP.NET 2.0 Basics 5 February 22nd, 2007 03:12 PM
Convert DBNull to String GailCG ASP.NET 2.0 Basics 1 November 21st, 2006 02:16 AM
setting DBNull to a string in a dataset at runtime texasraven Classic ASP Professional 2 September 3rd, 2003 04:28 PM



All times are GMT -4. The time now is 06:57 PM.


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