Why a SqlParameter does not get value?

creative4w3

New Member
I am trying to initialize the value of a \[code\]SqlParameter\[/code\] with a string. but why does it not get the value ?This is what I tried:\[code\] int loadChart(string status) { connect(); SqlParameter[] parameters ={ new SqlParameter("status", SqlDbType.VarChar, 10), new SqlParameter("count", SqlDbType.Int, 4) }; parameters[0].Value = http://stackoverflow.com/questions/12680225/status; parameters[1].Direction = ParameterDirection.Output; SqlCommand cmd = new SqlCommand("sp_Arsenic_getSourceStatusCount", objConnection); foreach (SqlParameter param in parameters) { cmd.Parameters.Add(param); } cmd.ExecuteNonQuery(); disConnect(); int count; count =(int) parameters[1].Value; return count; }}\[/code\]The stored procedure:\[code\]alter procedure sp_Arsenic_getSourceStatusCount@status varchar(10),@count intasselect @count=COUNT(status) from Arsenic_WaterSource where status=@statusreturn 1\[/code\]Inserting a breakpoint I have discovered that the string variable \[code\]status\[/code\] gets its value "safe" but at \[code\]parameters[0].Value = http://stackoverflow.com/questions/12680225/(string) status;\[/code\] line \[code\]parameters[0].value\[/code\] gets \[code\]null\[/code\]. How to resolve this issue ?
 
Back
Top