Click here to Skip to main content
15,885,915 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
// this is my stored precedure
private string LastPlanDate(string WPMID, string SchoolAcaID, string SchoolMasterID)
    {
        try
        {
            cT.WPMID = Convert.ToInt32(WPMID);
            cT.Schoolacaid= _objSession.schoolAcaID;
            cT.Schoolmasterid = _objSession.smid;
            DataSet ds = cT.GetWeeklyPlanlastplandays();
           
            return ds.Tables[0].Rows[0]["Date"].ToString();

        }
        catch (Exception ex)
        {
            Log.Message(ex);
            throw ex;
        }
    }


What I have tried:

public DataSet GetWeeklyPlanlastplandays()
    {
        DataSet ds = new DataSet();
        try
        {
            cmd = new SqlCommand("Sms_WeeklyPlanLastPlandays", dAL.con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@WPMID", WPMID);
            cmd.Parameters.AddWithValue("@Schoolmasterid", Schoolmasterid);
            cmd.Parameters.AddWithValue("@Schoolacaid", Schoolacaid);
            SqlDataAdapter sqlDA = new SqlDataAdapter(cmd);
            sqlDA.Fill(ds);
        }
        catch (Exception ex)
        {
            Log.Message(ex.ToString());
        }
        return ds;

    }
Posted
Updated 21-Feb-22 1:51am
Comments
CHill60 21-Feb-22 7:18am    
What is actually happening / not happening

1 solution

That's not a stored procedure: that is C# code and stroed procedures are written in SQL, because that is where they are executed.
This is a stored procedure:
SQL
ALTER PROCEDURE [dbo].[spCountEpisodes] 
AS
BEGIN
	SET NOCOUNT ON;
    SELECT a.Name, b.EpCount 
    FROM Serials a 
    JOIN 
      (SELECT SerialId, Count(SerialNo) AS EpCount 
       FROM Episode GROUP BY SerialId) AS b 
    ON a.Id = b.SerialId
END

Your second example executes a stored procedure and uses it to fill a DataSet - but we have no idea what the SP does, how it does it, what data you pass to it in the parameters, or what your database contains.

So start with the debugger and look at the parameter values. then use SSMS to look inside your Db at the SP and your database table content to find out what it should be returning.

Sorry, but we can't help you with that!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900