1

I am running this stored procedure with .NET like so:

public List<showWhatClass> showWhatMethod(string deviceWhat, int tagWhat, Decimal latit, Decimal longit, int Process, string CallNext, int CallNextVar)
{
    showWhatCell = new List<showWhatClass>();

    try
    {
        using (connection = new SqlConnection(connectionString))
        {
            using (SqlCommand command = new SqlCommand("iosShowWhat", connection))
            {
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@DeviceId", deviceWhat);
                command.Parameters.AddWithValue("@TagId", tagWhat);
                command.Parameters.AddWithValue("@Latitude", latit);
                command.Parameters.AddWithValue("@Longitude", longit);
                command.Parameters.AddWithValue("@Process", Process);
                command.Parameters.AddWithValue("@CallNext", CallNext);
                command.Parameters.AddWithValue("@CallNextVar", CallNextVar);

                connection.Open();
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    showWhatClass item = new showWhatClass();
                    item.CallNext = reader.GetValue(0).ToString();
                    item.CallNextVar = (int)reader.GetValue(1);
                    showWhatCell.Add(item);
                }
            }
        }
    }
    finally
    {
        connection.Close();
    }

    return showWhatCell;
}

The stored procedure returns the following message:

enter image description here

When I run this I get the following returned:

<ArrayOfshowWhatClass xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/WebServiceAPI.Models"/>

which is empty

my question is what am I doing wrong, how come nothing is returning when I run this with .NET but does return the message in SQL Server.

Here is my showWhatClass

public class showWhatClass
{
        public string CallNext { get; set; }
        public int CallNextVar { get; set; }
}
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user979331
  • 11,039
  • 73
  • 223
  • 418

1 Answers1

0

Try to change your parameters:

command.Parameters.AddWithValue("@DeviceId", deviceWhat);

to the following:

command.Parameters.Add("@DeviceId", SqlDbType.Int).Value = deviceWhat;
Khazratbek
  • 1,656
  • 2
  • 10
  • 17