im trying to update my db doing:
int index = grdExcUsePolicy.EditIndex;
GridViewRow row = grdExcUsePolicy.Rows[index];
string id = ((Label)row.FindControl("lblId")).Text;
String name = ((TextBox)row.FindControl("txtName")).Text;
String created = ((TextBox)row.FindControl("txtCreated")).Text;
if (gridUtil.getInsertMode())
{
}
else
{
GeneralDbExecuterService.executeSqlNonQuery(string.Format("UPDATE EXCEPTIONAL_USE_POLICY_PARAM
SET NAME = '{0}', CREATED_DATE = to_date('{2}', 'dd/mm/yyyy') WHERE ID = '{1}' ", name, id,
created));
}
inside sql everything updates perfectly., and when performing the following code I can either update only date or both name date together, but I get an error trying to update name alone??.. also I checked and name isnt any kind of key. I basically have other tables and gridview that work fine, every column individually. I just copy paste it and change variables to the current table's needs. why am I getting the error?
important to add that my aspx. and aspx cs both copied and changed so code behind is the same, but still only here the eror Im getting
CodePudding user response:
If you do db update database from the control section, it will be fixed.
CodePudding user response:
I fixed it, the problem wasnt related to anything other than the reason somewhy when I tried to update name alone the db query pulled me a date with time and when I tried to change only date it was giving me just a date. so basically a collision between the correct format of the date.
before <asp:TextBox ID="txtCreated" runat="server" CssClass="txtEntryInput" name="datepicker" att="datepicker" Text='<%# Bind("CREATED_DATE")%>'></asp:TextBox>
after <asp:TextBox ID="txtCreated" runat="server" CssClass="txtEntryInput" name="datepicker" att="datepicker" Text='<%# Bind("CREATED_DATE", "{0:dd-M-yyyy}") %>' MaxLength="10"></asp:TextBox>