Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 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 May 9th, 2007, 08:16 AM
Registered User
 
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default not all code paths return a value c#

 DataSet LoadCompleteDataSet(string strConnection)
        {
            try
            {
                DataSet dsData = new DataSet();

                bool blnRunStoredProc = true;


                dsData = PopulateDataSetTable(strConnection, "Brand", "sp_1BrandSelect", blnRunStoredProc, ref dsData);
                dsData = PopulateDataSetTable(strConnection, "Company", "sp_CompanySelect", blnRunStoredProc,ref dsData);
                dsData = PopulateDataSetRelationship("Company", "Brand", "CompanyID", "CompanyID", "BrandVsCompany",ref dsData);
                return dsData;
            }
            catch
            {
                UnhandledExceptionHandler();
            }
        }


 void UnhandledExceptionHandler()
        {


        }

can anybody help me in removing this error
not all code paths return a value c#

Thanks & Regards


 
Old May 9th, 2007, 08:22 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You need to specify a return value outside of your try catch.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old May 9th, 2007, 07:39 PM
Authorized User
 
Join Date: Feb 2004
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just add a "return null" at the end of your 'catch'.

 
Old May 9th, 2007, 11:53 PM
Registered User
 
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Everybody its work when i put "return null" after at the end of catch statement

 
Old May 10th, 2007, 04:17 AM
Friend of Wrox
 
Join Date: Apr 2007
Posts: 110
Thanks: 1
Thanked 2 Times in 2 Posts
Send a message via MSN to ayazhoda
Default

use final in your try catch exception it is best programming practice


 
Old May 10th, 2007, 08:02 AM
Authorized User
 
Join Date: May 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
You are returing the dataset inside the try block, suppose , if u got any error it will goes to catch,... there is no return ...
use try {....} catch{.....} and finally {....} ,, for best programming aspect.


In your case return null in ur catch block...


With Regards,
Muralidharan.D





Similar Threads
Thread Thread Starter Forum Replies Last Post
v urgent..Error: not all code paths return a value prv299 .NET Web Services 1 May 20th, 2008 06:17 AM
not all code paths return a value galua SQL Language 11 January 20th, 2008 09:36 PM
Hard coded paths pauliehaha Classic ASP Professional 8 February 6th, 2007 06:48 PM
paths table FT BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 December 12th, 2006 11:50 AM
Code to Remove Carriage Return From Spreadsheet Jersey Eric Excel VBA 2 May 12th, 2005 08:35 AM





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