Click here to Skip to main content
15,895,142 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionDBO access to ASPNET_ tables Pin
dasumohan5-Mar-07 17:41
dasumohan5-Mar-07 17:41 
Questionserial communication Pin
wnaiza5-Mar-07 17:36
wnaiza5-Mar-07 17:36 
AnswerRe: serial communication Pin
badgrs5-Mar-07 23:21
badgrs5-Mar-07 23:21 
GeneralRe: serial communication Pin
wnaiza6-Mar-07 15:50
wnaiza6-Mar-07 15:50 
QuestionError in remoting urgent help Pin
nikhil12345-Mar-07 17:24
nikhil12345-Mar-07 17:24 
Questioncall up current page using response.redirect or server.transfer Pin
dasumohan5-Mar-07 17:20
dasumohan5-Mar-07 17:20 
AnswerRe: call up current page using response.redirect or server.transfer Pin
Spunky Coder5-Mar-07 21:37
Spunky Coder5-Mar-07 21:37 
Question"Not all code paths return a value" - Error Message Pin
harni.a5-Mar-07 14:15
harni.a5-Mar-07 14:15 
Hi,
I am studying this book "Microsoft Visual C# 2005 Step by Step (by John Sharp)". I used a piece of code written in the book and I get an error message. Could you please help me fix it?

==========================================

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Configuration;
using System.Data.SqlClient;
using System.Diagnostics;

[WebService(Namespace = " http://www.contentmaster.com/WebSite3")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public string HelloWorld() {
return "Hello World";
}


[WebMethod]
public decimal Howmuch(string name,int q)
{
SqlConnection sqlcon = null;
try
{
ConnectionStringSettings cs = ConfigurationManager.ConnectionStrings ["productconnstring"];
string connnstring = cs.ConnectionString;
sqlcon = new SqlConnection(connnstring);
SqlCommand sqlcomd = new SqlCommand();
sqlcomd.CommandText = "SELECT StandardCost FROM Production.Product" + "WHERE Name= '" + name + "'";
sqlcomd.Connection = sqlcon;
sqlcon.Open();
decimal price = (decimal)sqlcomd.ExecuteScalar();
return (price * q);


}
catch (Exception ex)
{
Handlewebexception(ex);

}
finally
{
if (sqlcon != null)
sqlcon.Close();
}
}

//Local private method to handle exceptions

private void Handlewebexception(Exception e)
{
EventLog log = new EventLog("Application");
log.Source = "website3";
log.WriteEntry(e.Message, EventLogEntryType.Error);
}

}
=======================================================


I use:
--- Windows XP Professional SP2
--- Visual Studio 2005
--- Microsoft SQL Server 2005
--- AdventureWorks Database

Error Message when I do "Build Website" - "Error 1 'Service.Howmuch(string, int)': not all code paths return a value C:\Documents and Settings\Srivathsan\My Documents\Visual Studio 2005\WebSites\WebSite3\App_Code\Service.cs 26 18 C:\...\WebSite3\ "

Please let me know how to fix it. I believe there is something wrong with return statements (absence of it somewhere). I am unable to figure out.

I would appreciate any suggestions,
Harni.
AnswerRe: "Not all code paths return a value" - Error Message Pin
rmedo5-Mar-07 15:46
rmedo5-Mar-07 15:46 
AnswerRe: "Not all code paths return a value" - Error Message Pin
Vasudevan Deepak Kumar6-Mar-07 9:33
Vasudevan Deepak Kumar6-Mar-07 9:33 
GeneralRe: "Not all code paths return a value" - Error Message Pin
harni.a7-Mar-07 17:15
harni.a7-Mar-07 17:15 
QuestionMy web service doesn't seem to update when I compile it Pin
goldoche5-Mar-07 10:31
goldoche5-Mar-07 10:31 
AnswerRe: My web service doesn't seem to update when I compile it Pin
minhpc_bk5-Mar-07 13:48
minhpc_bk5-Mar-07 13:48 
GeneralRe: My web service doesn't seem to update when I compile it Pin
goldoche6-Mar-07 2:23
goldoche6-Mar-07 2:23 
QuestionConverting an URL to a link Pin
nikneem20055-Mar-07 8:38
nikneem20055-Mar-07 8:38 
AnswerRe: Converting an URL to a link Pin
Vasudevan Deepak Kumar5-Mar-07 9:18
Vasudevan Deepak Kumar5-Mar-07 9:18 
Questionsaving image in sql database Pin
rmedo5-Mar-07 6:39
rmedo5-Mar-07 6:39 
AnswerRe: saving image in sql database Pin
nikneem20055-Mar-07 8:48
nikneem20055-Mar-07 8:48 
AnswerRe: saving image in sql database Pin
Vasudevan Deepak Kumar5-Mar-07 9:18
Vasudevan Deepak Kumar5-Mar-07 9:18 
GeneralRe: saving image in sql database Pin
rmedo5-Mar-07 15:51
rmedo5-Mar-07 15:51 
GeneralRe: saving image in sql database Pin
Vipin.d5-Mar-07 19:47
Vipin.d5-Mar-07 19:47 
AnswerRe: saving image in sql database Pin
Vipin.d5-Mar-07 20:13
Vipin.d5-Mar-07 20:13 
QuestionImplementing breadcrumbs as an usercontrol! Pin
Deepasubramanian5-Mar-07 6:35
Deepasubramanian5-Mar-07 6:35 
AnswerRe: datagrid part not your control part Pin
Naveed Kamboh5-Mar-07 7:02
Naveed Kamboh5-Mar-07 7:02 
GeneralRe: datagrid part not your control part Pin
Deepasubramanian5-Mar-07 14:52
Deepasubramanian5-Mar-07 14:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.