using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data.SqlClient;
using System.Configuration;
using System.Text;
namespace Auto_WebService
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://webservices/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string GetListOfCountries()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connection1"].ToString());
con.Open();
string str="select Name from AccountBase where len(isnull(name,'')) > 0";
SqlDataAdapter da=new SqlDataAdapter(str,con);
DataSet ds=new DataSet();
da.Fill(ds);
StringBuilder sb=new StringBuilder();
for (int i = 0; i < ds.Tables[0].Rows.Count ; i++)
{
sb.Append(ds.Tables[0].Rows[i][0].ToString() + ",,");
}
//return string.Join(",,", arrayCountries);
return sb.ToString();
con.Close();
//return "Hello World";
}
}
}
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data.SqlClient;
using System.Configuration;
using System.Text;
namespace Auto_WebService
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://webservices/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string GetListOfCountries()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connection1"].ToString());
con.Open();
string str="select Name from AccountBase where len(isnull(name,'')) > 0";
SqlDataAdapter da=new SqlDataAdapter(str,con);
DataSet ds=new DataSet();
da.Fill(ds);
StringBuilder sb=new StringBuilder();
for (int i = 0; i < ds.Tables[0].Rows.Count ; i++)
{
sb.Append(ds.Tables[0].Rows[i][0].ToString() + ",,");
}
//return string.Join(",,", arrayCountries);
return sb.ToString();
con.Close();
//return "Hello World";
}
}
}
No comments:
Post a Comment