Good, I would like you to help me.
I am commenting that I am doing a webservice that returns me in a List , I am using Dos Capas in: 1.Web Service 2.Capa Datos
The Code of my Webservice is the following:
public class Heldesk : System.Web.Services.WebService
{
D_Usp_LlenarCombos obj = new D_Usp_LlenarCombos();
[WebMethod]
public List<Combos> Ws_LlenarCombo(Int32 Opt,Int32 Id_Tipo)
{
return obj.D_LlenarCombo(Opt, Id_Tipo);
}
}
Create a Data Class to attach to the List < > that has the following:
public class Combos
{
public string Id { get; set; }
public Int32 Nombre { get; set; }
}
and in my data layer the following:
public List<Combos> D_LlenarCombo(Int32 Opt, Int32 Id_Tipo)
{
SqlDataReader reader;
SqlConnection cn = new SqlConnection(ObtenerCadenaConexion());
cn.Open();
SqlCommand cmd = new SqlCommand("LlenarCombo", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@opt", SqlDbType.Int).Value = Opt;
cmd.Parameters.Add("@Id_Tipo", SqlDbType.Int).Value = Id_Tipo;
reader= cmd.ExecuteReader();
List<Combos> Combo = new List<Combos>();
try
{
while (reader.Read())
{
Combo.Add(reader.GetValue(0), reader.GetValue(1));
}
reader.Close();
cmd.Dispose();
cn.Close();
return D_LlenarCombo(Opt, Id_Tipo);
}
catch (Exception Ex)
{
throw new Exception(Ex.Message);
}
This is my Procedure:
create procedure llenarcombos
@opt int,
@Id_Tipo int
as
if @opt=1
begin
select Id_Tipoincidencia,TipoIncidencia from Ms_TipoIncidencia
end
What I want is for you to vote for this result
Id_Tipoincidencia TipoIncidencia
1 Incidencia de Aplicativo
2 Bank Plus
3 Base de datos
The problem that I do not get the results, I vote this error.
If you could help me.
What I really want is to consume that service and add it in a combobox