Friday, December 24, 2021

Stored Procedure with Sql Parameter in c#

using (SqlCommand cmd = new SqlCommand("sp_getrewardincome", con))
{
    cmd.CommandType = CommandType.StoredProcedure;
    SqlDataAdapter ad = new SqlDataAdapter(cmd);
    cmd.Parameters.AddWithValue("@id", id);
    cmd.Parameters.AddWithValue("@type", "update");
    dt = new DataTable();
    ad.Fill(dt);
   
}


using (SqlCommand cmd = new SqlCommand("sp_getrewardincome", con))
{
    cmd.CommandType = CommandType.StoredProcedure;
    SqlDataAdapter ad = new SqlDataAdapter(cmd);
    cmd.Parameters.AddWithValue("@id", id);                    
    cmd.Parameters.AddWithValue("@type", "update");
    //cmd.Parameters.Add("@result", SqlDbType.NVarChar, 3000);
    //SqlParameter ptr = cmd.Parameters["@result"];
    //ptr.Direction = ParameterDirection.Output;
    con.Open();
    cmd.ExecuteNonQuery();    
}

 

No comments:

Post a Comment

Linq Expression syntax for where condtion in linq

(Expression<Func<T, bool>> filter)