I am inserting data and time
below error is coming
Error converting data type nvarchar to datetime.
Create Proc SP_Insert_TIme
@A_Date datetime,
@EmpID int
as begin
inert into AttendenceLOG (EnrollNumber,A_Date) values (@EmpID,@A_Date)
end
<td align="right" style="width: 50%;">Employee : </td>
<td align="left" style="width: 50%">
<asp:DropDownList ID="ddlEmployee" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr style="width: 100%">
<td align="right" style="width: 50%;">DateFrom : </td>
<td align="left" style="width: 50%">
<asp:TextBox ID="txtDateFrom" runat="server" TextMode="DateTimeLocal" Width="265px"></asp:TextBox>
</td>
</tr>
<tr style="width: 100%">
<td align="right" style="width: 50%;"> </td>
<td align="left" style="width: 50%"> </td>
</tr>
<tr style="width: 100%">
<td align="center" colspan="2">
<asp:Button ID="Save" runat="server" OnClick="btnSearch_Click" Text="Search" />
</td>
protected void btnSearch_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("SP_Insert_TIme", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@EmpID", ddlEmployee.SelectedValue);
cmd.Parameters.AddWithValue("@A_Date", txtDateFrom.Text.ToString());
// cmd.Parameters.AddWithValue("@IPAddress", lblIP.Text);
// cmd.Parameters.AddWithValue("@DDate", DateTime.Now);
// cmd.Parameters.AddWithValue("@D_Time", DateTime.Now.ToString("hh:mm"));
con.Open();
cmd.ExecuteNonQuery();
con.Close();
// lbmsg.Text = "Item Save Successfully";
//TextBox1.Text = string.Empty;
//TextBox4.Text = string.Empty;
}