I have the strangest issue. The following works most of the time, however "now and again" it fails to return data, even though I have put a breakpoint for the adapter.fill statement, checked the params and executed them via SQL Management Studio which definitely returns the data :)
So this is a standard c# SQL client call:
SqlCommand command = new SqlCommand();
command.CommandType = CommandType.StoredProcedure;
command.Connection = connection;
The connection is definitely being opened ok, and used because it is also being used via another call.. and actually subsequent calls work too.. however, again in my case the following "sometimes" fails:
command.CommandText = "myprocname";
command.Parameters.AddWithValue("@param1", param1value);
command.Parameters.AddWithValue("@param2", param2value);
command.Parameters.AddWithValue("@param3", param3value);
command.Parameters.AddWithValue("@param4", param4value);
and then to fill the dataset:
DataSet ds = new DataSet();
using (SqlDataAdapter adapter = new SqlDataAdapter(command))
{
adapter.Fill(ds);
}
command.Dispose();
So really nothing strange going on, and the above works most of the time.. on the occasion it didn't return what I expected, and put a breakpoint in just before the adapter.fill statement, checked the commandtext and each of the parameters/values being passed.. opened up sql management studio, ran the proc with those params, and sure enough the expected data was returned.
The proc is very simple, and again most of the time returned the data...
I cannot fault the proc in anyway, however this is driving my crazy as I have checked connection timeouts, timings of execution and so on.. I guess the craziest thing is that the proc name, and params are all correct (no extra params being passed by accident etc).. and running manually, it returns the data.. but via the fill statement it seems to NOT (but only occasionally!).
Any help with this madness much appreciated!!