Error Not All Code Paths Return A Value Asp Net
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions error not all code paths return a value in c# net you might have Meta Discuss the workings and policies of
Error 1 Not All Code Paths Return A Value
this site About Us Learn more about Stack Overflow the company Business Learn more about hiring not all code paths return a value c# developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is
Not All Code Paths Return A Value C# Mvc
a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Not all code paths return a value error in C# up vote -4 down vote favorite I am trying to load my charts from the Page_Load event but getting this error "not not all code paths return a value try catch all code paths return a value" and i am not sure what am I doing wrong here. Can someone help. Here is my code: protected void Page_Load(object sender, EventArgs e) { Literal2.Text = CreateChart_2(); } public string CreateChart_2() { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString); // Initialize the string which would contain the chart data in XML format StringBuilder xmlStr = new StringBuilder(); // Provide the relevant customization attributes to the chart xmlStr.Append("
here for a quick overview of the site Help Center Detailed answers to any
Not All Code Paths Return A Value Unity
questions you might have Meta Discuss the workings and policies
Not All Code Paths Return A Value C# Datatable
of this site About Us Learn more about Stack Overflow the company Business Learn more about how to fix not all code paths return a value hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow http://stackoverflow.com/questions/14946323/not-all-code-paths-return-a-value-error-in-c-sharp is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Getting Error: Not all code paths return a value up vote 2 down vote favorite I am new to mvc C# and am stuck. Please advise on how to fix http://stackoverflow.com/questions/10731097/getting-error-not-all-code-paths-return-a-value this. I'm getting the error on Add. When I hover over the red squiggly line it says "Not all code paths return a value" public ActionResult Add(ShapeInputModel dto, FormCollection collection) { var model = new GeoRegions(); if (TryUpdateModel(model)) { var destinationFolder = Server.MapPath("/App_Data/KML"); var postedFile = dto.Shape; if (postedFile != null) { var fileName = Path.GetFileName(postedFile.FileName); var path = Path.Combine(destinationFolder, fileName); postedFile.SaveAs(path); //Save to Database Db.AddGeoRegions(model); return RedirectToAction("Index"); } return View(); } } c# share|improve this question edited May 24 '12 at 4:21 Icarus 45.6k85386 asked May 24 '12 at 4:20 user1382770 92129 add a comment| 10 Answers 10 active oldest votes up vote 3 down vote accepted Use This : public ActionResult Add(ShapeInputModel dto, FormCollection collection) { var model = new GeoRegions(); if (TryUpdateModel(model)) { var destinationFolder = Server.MapPath("/App_Data/KML"); var postedFile = dto.Shape; if (postedFile != null) { var fileName = Path.GetFileName(postedFile.FileName); var path = Path.Combine(destinationFolder, fileName); postedFile.SaveAs(path); //Save to Database Db.AddGeoRegions(model); return RedirectToActio
Tips/Tricks Top Articles Beginner Articles Technical Blogs Posting/Update Guidelines Article Help Forum Article Competition Submit an article or tip Post your http://www.codeproject.com/Questions/303345/Not-all-code-paths-return-a-value-Please-explain-a Blog quick answersQ&A Ask a Question View Unanswered Questions View All https://msdn.microsoft.com/en-us/library/87cz4k9t.aspx Questions... C# questions Linux questions ASP.NET questions SQL questions VB.NET questions discussionsforums All Message Boards... Application Lifecycle> Running a Business Sales / Marketing Collaboration / Beta Testing Work Issues Design and Architecture ASP.NET JavaScript C / C++ / MFC> ATL / WTL / STL not all Managed C++/CLI C# Free Tools Objective-C and Swift Database Hardware & Devices> System Admin Hosting and Servers Java .NET Framework Android iOS Mobile SharePoint Silverlight / WPF Visual Basic Web Development Site Bugs / Suggestions Spam and Abuse Watch features Competitions News The Insider Newsletter The Daily Build Newsletter Newsletter archive Surveys Product Showcase Research not all code Library CodeProject Stuff communitylounge Who's Who Most Valuable Professionals The Lounge The Insider News The Weird & The Wonderful The Soapbox Press Releases Non-English Language > General Indian Topics General Chinese Topics help What is 'CodeProject'? General FAQ Ask a Question Bugs and Suggestions Article Help Forum Site Map Advertise with us About our Advertising Employment Opportunities About Us Ask a Question All Questions All Unanswered FAQ "Not all code paths return a value". Please explain about this error. Rate this: Please Sign up or sign in to vote. See more: C# "Not all code paths return a value". Please explain about this error. Posted 20-Dec-11 19:47pm maajanes698 Add a Solution Comments RaisKazi 21-Dec-11 1:48am Post your code. Al Moje 21-Dec-11 1:54am You made a function or method that expects to return an explicit value but you fail to do... 4 solutions Top Rated Most Recent Rate this: Please Sign up or sign in to vote. So
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Retired content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. MSDN Library MSDN Library MSDN Library MSDN Library Design Tools Development Tools and Languages Mobile and Embedded Development .NET Development Office development Online Services Open Specifications patterns & practices Servers and Enterprise Development Speech Technologies Web Development Windows Desktop App Development TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. Compiler Error CS0161 Other Versions Visual Studio 2008 Visual Studio 2005 Visual Studio .NET 2003 'method': not all code paths return a valueA method that returns a value must have a return statement in all code paths. For more information, see Methods (C# Programming Guide).The following sample generates CS0161: Copy // CS0161.cs public class Test { public static int Main() // CS0161 { int i = 10; if (i < 10) { return i; } else { // uncomment the following line to resolve // return 1; } } } Show: Inherited Protected Print Export (0) Print Export (0) Share IN THIS ARTICLE Is this page helpful? Yes No Additional feedback? 1500 characters remaining Submit Skip this Thank you! We appreciate your feedback. Dev centers Windows Office Visual Studio Microsoft Azure More... Learning resources Microsoft Virtual Academy Channel 9 MSDN Magazine Community Forums Blogs Codeplex Support Self support Programs BizSpark (for startups) Microsoft Imagine (for students) United States (English) Newsletter Privacy & cookies Terms of use Trademarks © 2016 Microsoft © 2016 Microsoft