Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SQL
DROP PROCEDURE IF EXISTS hms.Select_LastDate_Result;
CREATE PROCEDURE hms.`Select_LastDate_Result`()
BEGIN
      SELECT Current_Test_Date as 'Last_Date'
                FROM patient_progress_tracking_details
              ORDER BY Current_Test_Date DESC limit 1;
       SELECT Test_Result as 'Result'
                FROM patient_progress_tracking_details
              ORDER BY Current_Test_Date DESC limit 1;
   END;

this is my cs file..
C#
protected void Imgbtnsave_Click(object sender, ImageClickEventArgs e)
       {

           MySqlConnection StrConnection = null;
           MySqlCommand StrCommand = null;
           try
           {
               StrConnection = new MySqlConnection();
               StrConnection.ConnectionString = StrConn;
               StrConnection.Open();

               StrCommand = new MySqlCommand();
               StrCommand.CommandType = CommandType.StoredProcedure;
               StrCommand.CommandText = "Select_LastDate_Result";
               StrCommand.Connection = StrConnection;

               StrCommand.ExecuteNonQuery();
               BindCarePlan();
           }
           catch (Exception ex)
           {
               obj.InfoEntry(DateTime.Now + "     " + "BtnSave1_Click" + "     " + "AccountBalance.aspx" + "     " + ex.Message, "");
               obj.InfoEntry(DateTime.Now + "     " + ex.StackTrace, "");
               Session["strerrormsg"] = DateTime.Now + "     " + "BtnSave1_Click" + "     " + "AccountBalance.aspx" + "     " + ex.Message;
               Session["strerrortrace"] = DateTime.Now + "     " + ex.StackTrace;
               Response.Redirect("ErrorPage.aspx");
           }
           finally
           {
               StrConnection.Close();
               StrConnection.Dispose();
           }
       }
   }

this code is not working..
Posted
Updated 4-Jan-13 21:38pm
v2
Comments
demouser743 5-Jan-13 6:54am    
Any error?

 
Share this answer
 
Comments
Sandeep Mewara 5-Jan-13 3:39am    
Sure would help. My 5!
Abhinav S 5-Jan-13 4:24am    
Thanks Sandeep.
StrConnection.ConnectionString = StrConn;
StrConnection.Open();

StrCommand = new MySqlCommand();
StrCommand.CommandType = CommandType.StoredProcedure;
StrCommand.CommandText = "Select_LastDate_Result";
StrCommand.Connection = StrConnection;

instead above code use following:

StrCommand= new SqlCommand("Select_LastDate_Result", StrConnection);
cmd.CommandType = CommandType.StoredProcedure;
connection.Open();
 
Share this answer
 
you can do it so many ways but i give you simple ways

that is you change your SP
LIke:-

CREATE PROCEDURE hms.`Select_LastDate_Result`()
BEGIN
SELECT Current_Test_Date as 'Last_Date',Test_Result as 'Result'
FROM patient_progress_tracking_details
ORDER BY Current_Test_Date DESC limit 1;

--------------------------------
then you call this stored procedure as you calling above;

and other way you can used using out parameter sql

to search out parameter click following link:-

http://msdn.microsoft.com/en-us/library/ms187004(v=sql.105).aspx[^]

http://sqlserverpedia.com/wiki/Stored_Procedures_-_Output_Parameters_%26_Return_Values[^]



if problem exist than give your comment.....
 
Share this answer
 
Comments
ujali 5-Jan-13 11:02am    
thank u...this is what want...

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