Click here to Skip to main content
12,360,217 members (61,982 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET MySQL
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..
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 4-Jan-13 21:21pm
ujali450
Updated 4-Jan-13 21:38pm
v2
Comments
Dorababu743 5-Jan-13 6:54am
   
Any error?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Sandeep Mewara 5-Jan-13 3:39am
   
Sure would help. My 5!
Abhinav S 5-Jan-13 4:24am
   
Thanks Sandeep.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

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();
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

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.....
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 5 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100