Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET 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
Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 10th, 2004, 03:14 AM
Friend of Wrox
 
Join Date: Sep 2003
Location: Mentiri, Muara, Brunei.
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default Comparing DBNull

Hello,

  I have a table with two fields
brand_code Text(2) PK
brand_name Varchar(20)

Brand_code is generated automatically. If no records are there in the table the new brand_code will be "01"

else right("00" & max(brand_code)+1,2)

select max(convert(integer,brand_code)) from brands

How can i read the value? I tried with Sqldatareader
dr=cmd.executereader()

How can i know whether it has retrieved any rows or not.
If i run this query from SQLQueryAnalyzer it returns a row with NULL coz no records initially.
How can i read that value?

Thanx in advance

  #2 (permalink)  
Old December 10th, 2004, 11:13 AM
Authorized User
 
Join Date: Nov 2004
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If i understand your problem the following should solve it:

int barCode;
object temp = cmd.ExecuteScalar();
if(temp==null)
    barCode=1;
else
    barCode = ((int)temp)+1;
Closed Thread


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
The DBNull Class and IsDBNull Function dschnedar BOOK: Professional Visual Basic 2008 ISBN: 978-0-470-19136-1 1 September 27th, 2008 09:13 AM
Convert DBNull to String GailCG ASP.NET 2.0 Basics 1 November 21st, 2006 02:16 AM
String="" convert to DBNull bekim ASP.NET 1.0 and 1.1 Basics 1 February 28th, 2006 01:28 AM
How to Check DBNull while binding controls narendra_patil General .NET 6 May 13th, 2005 07:20 AM
Dealing with DBNull jaucourt VB.NET 2002/2003 Basics 3 January 16th, 2004 10:59 AM



All times are GMT -4. The time now is 03:46 AM.


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