I am stuck with an issue of passing a string value as a parameter to a stored procedure in C# ASP.NET MVC. Any help is greatly appreciated.
I tried various options of setting the parameter, like
cmd.Parameters.AddWithValue("@P_ORG", pOrg);
cmd.Parameters.Add(pOrg);
Code snippet:
using (SqlConnection con = new SqlConnection(cs))
{
con.Open();
SqlParameter param = new SqlParameter()
{
ParameterName = "@P_ORG",
Value = pOrg
};
SqlCommand cmd = new SqlCommand("getCCM", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(param);
using (SqlDataReader rdr = cmd.ExecuteReader())
{
//do something
}
}
pOrgcan you edit this and show all relevant code as it pertains to your issue..?pOrgvalue and where it's being assigned.. it would be nice to see the actual Stored Procedure thoughSqlDbType = SqlDbType.VarCharwill help.