The method hello() is supposed to return a string, which it is not returning.
Add a return "some string" at the end of the method. If you need to return the dataset, then change the method signature to return a dataset and return the dataset at the end of the method implementation.
I blog at http://rajeshpillai.net and have a community startup http://ownabook.org/
(Don't forget to click "Mark as Answer" on the post(s) that helped you.)
abdhulrazeed...
Member
8 Points
88 Posts
Error in Public method
Apr 26, 2012 05:13 AM|LINK
Error 1 'Service.hello()': not all code paths return a value D:\maddy\WebSite2\App_Code\Service.cs 31 19 D:\maddy\WebSite2\
[WebMethod]
public string hello()
{
string sConn = ConfigurationManager.ConnectionStrings["travel"].ToString();
string sSQL = "select *from tbl_login";
SqlConnection connCustomer = new SqlConnection(sConn);
DataSet dsCustomer = new DataSet();
SqlDataAdapter daCustomer = new SqlDataAdapter(sSQL, sConn);
daCustomer.Fill(dsCustomer,"Customers");
}
thinkrajesh
Participant
1356 Points
232 Posts
Re: Error in Public method
Apr 26, 2012 05:18 AM|LINK
The method hello() is supposed to return a string, which it is not returning.
Add a return "some string" at the end of the method. If you need to return the dataset, then change the method signature to return a dataset and return the dataset at the end of the method implementation.
(Don't forget to click "Mark as Answer" on the post(s) that helped you.)
harsh.cer
Participant
1107 Points
161 Posts
Re: Error in Public method
Apr 26, 2012 05:19 AM|LINK
Hi Friend,
following will help you.
[WebMethod]
public DataSet hello()
{
string sConn = ConfigurationManager.ConnectionStrings["travel"].ToString();
string sSQL = "select *from tbl_login";
SqlConnection connCustomer = new SqlConnection(sConn);
DataSet dsCustomer = new DataSet();
SqlDataAdapter daCustomer = new SqlDataAdapter(sSQL, sConn);
daCustomer.Fill(dsCustomer,"Customers");
return dsCustomer;
}
Harshal D.
Software Engineer
Remember to click “Mark as Answer” on the post If you get answer from my post(s) !
abdhulrazeed...
Member
8 Points
88 Posts
Re: Error in Public method
Apr 26, 2012 05:34 AM|LINK
still same error
sriramabi
Contributor
4351 Points
1277 Posts
Re: Error in Public method
Apr 26, 2012 05:50 AM|LINK
Hai
try this
[WebMethod]
public static DataView hello()
{
string sConn = ConfigurationManager.ConnectionStrings["travel"].ToString();
string sSQL = "select *from tbl_login";
SqlConnection connCustomer = new SqlConnection(sConn);
DataSet dsCustomer = new DataSet();
SqlDataAdapter daCustomer = new SqlDataAdapter(sSQL, sConn);
daCustomer.Fill(dsCustomer,"Customers");
return dsCustomer .Tables[0].DefaultView;
}
Thank u
jigarbjpatel
Member
454 Points
88 Posts
Re: Error in Public method
Apr 26, 2012 06:14 AM|LINK
[WebMethod] public string hello() { string sConn = ConfigurationManager.ConnectionStrings["travel"].ToString(); string sSQL = "select *from tbl_login"; SqlConnection connCustomer = new SqlConnection(sConn); DataSet dsCustomer = new DataSet(); SqlDataAdapter daCustomer = new SqlDataAdapter(sSQL, sConn); daCustomer.Fill(dsCustomer,"Customers"); return "hello"; }You need to return some string from the function. Check the return statement.
sriramabi
Contributor
4351 Points
1277 Posts
Re: Error in Public method
Apr 26, 2012 06:22 AM|LINK
You are Used webmethode.So only use static ..Becs static method call before pageload event....
then the static method call time not create object.only use classname dot(.) methode name..
for example
ie:ClassName Hai...
staticMethodeName:hellow
now we call this methode any page use this way
Hai.Hellow();
Hai is classname,hellow is static method name...
pls try cheers......
thank u