Click here to Skip to main content
15,879,326 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
DROP PROCEDURE IF EXISTS hms.UpdateCarePlan1;

CREATE PROCEDURE hms.`UpdateCarePlan1`(_Target_value             int,
                                       _Current_Test_Date        Date,
                                       _Test_Result              varchar(50),
                                       _Measurement_Frequency    varchar(50),
                                       _Next_Due_Date            Date,
                                       _Patient_Id               int,
                                       _ParameterId              int,
                                       _Modified_Date            datetime,_date datetime)
   BEGIN
      UPDATE    patient_progress_tracking_details c
             INNER JOIN
                patient_progress_tracking_header b
             ON b.Id = c.Id
         SET c.Target_Value = _Target_value,
             c.Measurement_Frequency = _Measurement_Frequency,
             c.Test_Result = _Test_Result,
             c.Current_Test_Date = _Current_Test_Date,
             c.Next_Due_Date = _Next_Due_Date,
             c.Modified_Date = _Modified_Date,
             b.Modified_Date=_date
       WHERE c.Patient_Id = _Patient_Id AND c.ParameterId = _ParameterId;
   END;


C#
protected void grdcareplan_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
         string ParameterId = Convert.ToString(grdcareplan.DataKeys[e.RowIndex].Value);
         TextBox txttargetvalue = (TextBox)grdcareplan.Rows[e.RowIndex].FindControl("txttargetvalue");
         TextBox txttestdate = (TextBox)grdcareplan.Rows[e.RowIndex].FindControl("txttestdate");
            TextBox txttestresult = (TextBox)grdcareplan.Rows[e.RowIndex].FindControl("txttestresult");
            DropDownList ddlMeasurementFrequency = (DropDownList)grdcareplan.Rows[e.RowIndex].FindControl("ddlMeasurementFrequency");
            TextBox txtnextduedate = (TextBox)grdcareplan.Rows[e.RowIndex].FindControl("txtnextduedate");
            TextBox txtremarks = (TextBox)grdcareplan.Rows[e.RowIndex].FindControl("txtremarks");
            DateTime testdt = DateTime.ParseExact(txttestdate.Text, "yy/dd/MM", null);
            DateTime nextdate = DateTime.ParseExact(txtnextduedate.Text, "yy/dd/MM", null);
            MySqlConnection strConnection = null;
             MySqlCommand strCommand = null;
            try
            {
                strConnection = new MySqlConnection();
                strConnection.ConnectionString = StrConn;
                strConnection.Open();
                strCommand = new MySqlCommand();
                strCommand.Connection = strConnection;
                strCommand.CommandType = CommandType.StoredProcedure;
                strCommand.CommandText = "UpdateCarePlan1";
                strCommand.Parameters.AddWithValue("_Target_value", txttargetvalue.Text.ToString());
                strCommand.Parameters.AddWithValue("_Current_Test_Date", testdt);
                strCommand.Parameters.AddWithValue("_Test_Result", txttestresult.Text.ToString());
                strCommand.Parameters.AddWithValue("_Measurement_Frequency", ddlMeasurementFrequency.SelectedItem.Text.ToString());
                strCommand.Parameters.AddWithValue("_DiseaseId", ddlselectdisease.SelectedValue);
                strCommand.Parameters.AddWithValue("_Next_Due_Date", nextdate);
      strCommand.Parameters.AddWithValue("_ParameterId", ParameterId);
                strCommand.Parameters.AddWithValue("_Patient_Id", Convert.ToInt32(Session["DiagnosisClickId"]));
                strCommand.Parameters.AddWithValue("_Modified_Date", DateTime.Now);
                strCommand.Parameters.AddWithValue("_date", DateTime.Now);
                strCommand.ExecuteNonQuery();
                grdcareplan.EditIndex = -1;
                 BindCarePlan();
                ModalPopupExtender1.Show();
                Biomade.Visible = true;
            }

When I am running my code, at the time of updating, there is exception that Data truncated for column 'Modified_Date' at row1.
Please help me.
Posted
v3
Comments
Rockstar_ 18-Jan-13 1:52am    
Check all the data types in the stored procedure and in the strCommand. ex. the
first argument in stored procedure is int and what value u are passing at function.(.ToString())...
ujali 18-Jan-13 3:51am    
thanku..

1 solution

Can you show the table structure for patient_progress_tracking_details?

It seems to me the Modified_Date column in that table is not DateTime as you're trying to put into it.
 
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