G
Guest
i have this function which call an sp that has a return code
public SqlDataReader fn_SpecData(Int32 iDate, Int32 iRange, out Int32
iRowCount)
{
string constr =
ConfigurationManager.ConnectionStrings["arlcapConnectionString"].ConnectionString;
SqlConnection sqlcon1 = new SqlConnection(constr);
SqlCommand sqlcmd1 = sqlcon1.CreateCommand();
sqlcmd1.CommandType = CommandType.StoredProcedure;
sqlcmd1.CommandText = "sp_getRatingSummaryRange";
sqlcmd1.Parameters.AddWithValue("@iDate", iDate);
sqlcmd1.Parameters.AddWithValue("@iRange", iRange);
SqlParameter RowCount = sqlcmd1.Parameters.Add("@isOK", null);
RowCount.SqlDbType = SqlDbType.Int;
RowCount.Direction = ParameterDirection.ReturnValue;
sqlcon1.Open();
iRowCount = Convert.ToInt32(RowCount.Value);
return sqlcmd1.ExecuteReader(CommandBehavior.CloseConnection);
}
but the RowCount.Value does not return a value
i've tried a few variations but still no value
if i use the non query function i get a value, but was hoping to combine
*** this one will return a value:
public Int32 fn_getSectorCount()
{
// returns 0 invalid or 1 valid for a userid and password
string constr =
ConfigurationManager.ConnectionStrings["arlcapConnectionString"].ConnectionString;
SqlConnection sqlcon1 = new SqlConnection(constr);
SqlCommand sqlcmd1 = sqlcon1.CreateCommand();
sqlcmd1.CommandType = CommandType.StoredProcedure;
sqlcmd1.CommandText = "sp_getSectorCount";
SqlParameter rowcount = sqlcmd1.Parameters.Add("@rowcount", null);
rowcount.SqlDbType = SqlDbType.Int;
rowcount.Direction = ParameterDirection.ReturnValue;
sqlcon1.Open();
sqlcmd1.ExecuteNonQuery();
sqlcon1.Close();
sqlcmd1.Dispose();
sqlcon1 = null;
sqlcmd1 = null;
return Convert.ToInt32(rowcount.Value);
}
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)
kes
public SqlDataReader fn_SpecData(Int32 iDate, Int32 iRange, out Int32
iRowCount)
{
string constr =
ConfigurationManager.ConnectionStrings["arlcapConnectionString"].ConnectionString;
SqlConnection sqlcon1 = new SqlConnection(constr);
SqlCommand sqlcmd1 = sqlcon1.CreateCommand();
sqlcmd1.CommandType = CommandType.StoredProcedure;
sqlcmd1.CommandText = "sp_getRatingSummaryRange";
sqlcmd1.Parameters.AddWithValue("@iDate", iDate);
sqlcmd1.Parameters.AddWithValue("@iRange", iRange);
SqlParameter RowCount = sqlcmd1.Parameters.Add("@isOK", null);
RowCount.SqlDbType = SqlDbType.Int;
RowCount.Direction = ParameterDirection.ReturnValue;
sqlcon1.Open();
iRowCount = Convert.ToInt32(RowCount.Value);
return sqlcmd1.ExecuteReader(CommandBehavior.CloseConnection);
}
but the RowCount.Value does not return a value
i've tried a few variations but still no value
if i use the non query function i get a value, but was hoping to combine
*** this one will return a value:
public Int32 fn_getSectorCount()
{
// returns 0 invalid or 1 valid for a userid and password
string constr =
ConfigurationManager.ConnectionStrings["arlcapConnectionString"].ConnectionString;
SqlConnection sqlcon1 = new SqlConnection(constr);
SqlCommand sqlcmd1 = sqlcon1.CreateCommand();
sqlcmd1.CommandType = CommandType.StoredProcedure;
sqlcmd1.CommandText = "sp_getSectorCount";
SqlParameter rowcount = sqlcmd1.Parameters.Add("@rowcount", null);
rowcount.SqlDbType = SqlDbType.Int;
rowcount.Direction = ParameterDirection.ReturnValue;
sqlcon1.Open();
sqlcmd1.ExecuteNonQuery();
sqlcon1.Close();
sqlcmd1.Dispose();
sqlcon1 = null;
sqlcmd1 = null;
return Convert.ToInt32(rowcount.Value);
}
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)
kes