Hi im new to C#, this is driving me crazy, any help would be appreciated..
I have a sql stored proc which accepts parameters;
CREATE
(
in c#.net the ReportMode can be null, I keep getting this error;
{"Procedure or function 'Sp_GetGamingDefaults' expects parameter '@ReportMode', which was not supplied."}
here is the code, im sure im missing something simple.... im setting the @ReportMode as SqlDbType.Int
try
{
SqlCommand acommand = connection.CreateCommand();
acommand.CommandText = "BIM.dbo.Sp_GetGamingDefaults";
acommand.CommandType = CommandType.StoredProcedure;
acommand.Parameters.Add("@ReportMode", SqlDbType.Int);
acommand.Parameters.Add("@ModuleUID", SqlDbType.Int);
acommand.Parameters.Add("@LoadNulls", SqlDbType.Bit);
if (ReportMode == null)
acommand.Parameters["@ReportMode"].IsNullable = true;
acommand.Parameters["@LoadNulls"].Value = true;
}
else
acommand.Parameters["@LoadNulls"].Value = false;
acommand.Parameters["@ReportMode"].Value = ReportMode;
acommand.Parameters["@ModuleUID"].Value = ModuleUID;
acommand.Prepare();
SqlDataAdapter adapt = new SqlDataAdapter(acommand.CommandText, connection);
adapt.TableMappings.Add("Table", "defaults");
adapt.SelectCommand = acommand;
adapt.Fill(aDataSet);
acommand.Dispose();
adapt.Dispose();
catch (Exception e)
MessageBox.Show(e.Message);