I am working on ASP.NET Web API and when I ran this method I get this error An error has occurred.
public List<DeviceClass> CheckDevice(string device)
{
devices = new List<DeviceClass>();
using( connection = new SqlConnection(connectionString))
{
using (SqlCommand command = new SqlCommand("uspCheckDeviceID", connection))
{
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@sp", SqlDbType.VarChar).Value = device;
connection.Open();
using (SqlDataReader reader = command.ExecuteReader())
{
if(reader.HasRows)
{
if(reader.Read())
{
DeviceClass model = new DeviceClass();
model.DeviceId = reader.GetValue(0).ToString();
model.Name = reader.GetValue(1).ToString();
model.Owner = reader.GetValue(2).ToString();
devices.Add(model);
}
}
connection.Close();
}
}
}
return devices;
}
What I am trying to determine if its code or if its the server connection.
This is the stored procedure I got an example:
declare @sp varchar(30)
set @sp ='marksiphoneid'
exec uspCheckDeviceID @sp
Is there something wrong with the way I am trying to get results from my stored procedure?
The error is
Failed to load resource: the server responded with a status of 500 (Internal Server Error)