Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET MySQL
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;
 
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 17-Jan-13 20:14pm
ujali436
v3
Comments
Vijaychauhan0806 at 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 at 18-Jan-13 3:51am
   
thanku..

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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

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

  Print Answers RSS
0 Peter Leow 210
1 Abhinav S 155
2 Mika Wendelius 131
3 Sergey Alexandrovich Kryukov 125
4 TheRealSteveJudge 114
0 Sergey Alexandrovich Kryukov 8,613
1 OriginalGriff 6,536
2 Peter Leow 3,727
3 Zoltán Zörgő 3,456
4 Richard MacCutchan 2,442


Advertise | Privacy | Mobile
Web01 | 2.8.150123.1 | Last Updated 18 Jan 2013
Copyright © CodeProject, 1999-2015
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