Dear Sir,
please help me to remove mention error
I unable to remove mention error
Error :
Server Error in '/NEW_OCMS' Application.
String was not recognized as a valid DateTime.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: String was not recognized as a valid DateTime.
Source Error:
Line 235: SqlCommand cmd = new SqlCommand("select * from comp_box a ,emp b where a.EMP_ID=b.EMP_ID and STATUS_ID='02' and closing_date=closing_date)", con);
Line 236: // SqlCommand cmd = new SqlCommand("select * from comp_box,emp ", con);
Line 237: cmd.Parameters.Add("@closing_date", SqlDbType.DateTime).Value = DateTime.ParseExact(dateString, new string[] { "MM.dd.yyyy", "MM-dd-yyyy", "MM/dd/yyyy" }, provider, DateTimeStyles.None);
Line 238: SqlDataAdapter sda = new SqlDataAdapter(cmd);
Line 239: DataTable dt = new DataTable();
|
Source File: c:\inetpub\wwwroot\OCMS\OCMS\itdashboard.aspx.cs Line: 237
Stack Trace:
[FormatException: String was not recognized as a valid DateTime.]
System.DateTimeParse.ParseExactMultiple(String s, String[] formats, DateTimeFormatInfo dtfi, DateTimeStyles style) +12872663
System.DateTime.ParseExact(String s, String[] formats, IFormatProvider provider, DateTimeStyles style) +52
OCMS.itdashboard.refreshdata1() in c:\inetpub\wwwroot\OCMS\OCMS\itdashboard.aspx.cs:237
OCMS.itdashboard.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\OCMS\OCMS\itdashboard.aspx.cs:32
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +52
System.Web.UI.Control.OnLoad(EventArgs e) +97
System.Web.UI.Control.LoadRecursive() +61
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +693
|
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.9261.0
.aspx :
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" EmptyDataText="***COMPLAINT(S) NOT FOUND.***" BackColor="White" BorderColor="#999999"
BorderStyle="None" BorderWidth="1px" CellPadding="3" CssClass="auto-style3" Height="50px" Width="1905px" GridLines="Vertical">
<AlternatingRowStyle BackColor="#DCDCDC" />
<Columns>
<asp:TemplateField HeaderText="Sl. No.">
<ItemTemplate>
<asp:Label ID="lblRowNumber" Text='<%# Container.DataItemIndex + 1 %>' runat="server" />
</ItemTemplate>
<ItemStyle Width="60px"></ItemStyle>
</asp:TemplateField>
<asp:BoundField ItemStyle-Width="70px" DataField="COMP_ID" HeaderText="Comp.No.">
<ItemStyle Width="100px"></ItemStyle>
</asp:BoundField>
<asp:BoundField ItemStyle-Width="70px" DataField="EMP_ID" HeaderText="Emp.No.">
<ItemStyle Width="90px"></ItemStyle>
</asp:BoundField>
<asp:BoundField ItemStyle-Width="150px" DataField="EMP_NAME" HeaderText="Name">
<ItemStyle Width="160px"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="EMP_DSG" HeaderText="Designation">
<ItemStyle Width="180px"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="DEPT_ID" HeaderText="Department">
<ItemStyle Width="195px"></ItemStyle>
</asp:BoundField>
<asp:TemplateField HeaderText="Mobile">
<ItemTemplate>
<%# (!string.IsNullOrEmpty(Eval("PHONE_MOB").ToString()) && Eval("PHONE_MOB").ToString().Length > 10) ? "" + Eval("PHONE_MOB").ToString().Substring(2, 10) : Eval("PHONE_MOB").ToString() %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Intercom">
<ItemTemplate>
<asp:Label ID="lblintrcm" Text='<%# Eval("INTERCOM") %>' runat="server" />
</ItemTemplate>
<ItemStyle Width="80px"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="Complaint's Message">
<ItemTemplate>
<asp:Label ID="lblId" Text='<%# Eval("COMP_MESSAGE") %>' runat="server" /><br />
(<font color="blue"><i>Remark :<asp:Label ID="Label4" Text='<%# Eval("REMARKS") %>' runat="server" /> ,   Closed By :
<asp:Label ID="Label5" Text='<%# Eval("ATTEND_BY") %>' runat="server" /></i>)
</ItemTemplate>
<ItemStyle Width="710px"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="Lodge Date">
<ItemTemplate>
<asp:Label ID="lblDate" Text='<%# Eval("COMP_LODGE_DATE") %>' runat="server" DataFormatString="{0:dd/MM/yyyy}" />
</ItemTemplate>
<ItemStyle Width="500px"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="Closed Date">
<ItemTemplate>
<asp:Label ID="lblDate1" Text='<%# Eval("CLOSING_DATE") %>' runat="server" DataFormatString="{0:dd/MM/yyyy}" />
</ItemTemplate>
<ItemStyle Width="500px"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="Closed Hours">
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%#(Convert.ToDateTime(Eval("CLOSING_DATE")).Subtract(Convert.ToDateTime(Eval("COMP_LODGE_DATE")))).ToString() %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="710px"></ItemStyle>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<sortedascendingcellstyle backcolor="#F1F1F1" />
<sortedascendingheaderstyle backcolor="#0000A9" />
<sorteddescendingcellstyle backcolor="#CAC9C9" />
<sorteddescendingheaderstyle backcolor="#000065" />
</asp:GridView>
.c#
public void refreshdata1()
{
con.Open();
string dateString = "";
CultureInfo provider = CultureInfo.InvariantCulture;
//SqlCommand cmd = new SqlCommand("select * from comp_box where closing_date IS NULL ORDER BY COMP_ID DESC ", con);
// SqlCommand cmd = new SqlCommand("SELECT COMP_ID, EMP_ID, COMP_MESSAGE, COMP_LODGE_DATE, CLOSING_DATE, REMARKS, STATUS_ID,ATTEND_BY FROM comp_box where STATUS_ID='02' and COMP_LODGE_DATE=CAST(GETDATE() AS DATE)", con);
SqlCommand cmd = new SqlCommand("select * from comp_box a ,emp b where a.EMP_ID=b.EMP_ID and STATUS_ID='02' and closing_date=closing_date)", con);
// SqlCommand cmd = new SqlCommand("select * from comp_box,emp ", con);
cmd.Parameters.Add("@closing_date", SqlDbType.DateTime).Value = DateTime.ParseExact(dateString, new string[] { "MM.dd.yyyy", "MM-dd-yyyy", "MM/dd/yyyy" }, provider, DateTimeStyles.None);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
con.Close();
this.GridView2.DataSource = dt;
this.GridView2.DataBind();
}