ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.SqlException: Conversion failed when converting date and/or time from character string<p>Hi <a class="username" rel="akhter"> akhter</a>,</p> <p>Check below code it's working.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">Date : &lt;asp:TextBox runat=&#34;server&#34; ID=&#34;txtDate&#34; /&gt; &lt;br /&gt; &lt;asp:Button Text=&#34;Insert&#34; runat=&#34;server&#34; OnClick=&#34;Save&#34; /&gt; &lt;br /&gt; &lt;asp:GridView runat=&#34;server&#34; ID=&#34;gvDates&#34; runat=&#34;server&#34; AutoGenerateColumns=&#34;false&#34;&gt; &lt;Columns&gt; &lt;asp:BoundField DataField=&#34;DateData&#34; HeaderText=&#34;DateData&#34; /&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <pre class="brush: csharp">using System.Data.SqlClient; using System.Data; using System.Configuration;</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <pre class="brush: csharp">protected void Save(object sender, EventArgs e) { string constr = ConfigurationManager.ConnectionStrings[&#34;constr&#34;].ConnectionString; SqlConnection con = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(&#34;INSERT INTO InsertDate VALUES(@Date)&#34;, con); cmd.Parameters.AddWithValue(&#34;@Date&#34;, txtDate.Text); con.Open(); cmd.ExecuteNonQuery(); con.Close(); cmd = new SqlCommand(&#34;SELECT DateData FROM InsertDate&#34;, con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); gvDates.DataSource = dt; gvDates.DataBind(); }</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://i.imgur.com/uPrQHCL.gif" alt="" width="248" height="305" /></p> <p><span style="text-decoration: underline;"><strong>Database</strong></span></p> <p><span style="text-decoration: underline;"><strong><img src="https://i.imgur.com/ICq6LjA.jpg" alt="" width="192" height="99" /></strong></span></p>https://www.aspforums.net:443/Threads/112999/SqlException-Conversion-failed-when-converting-date-andor-time-from-character-string/https://www.aspforums.net:443/Threads/112999/SqlException-Conversion-failed-when-converting-date-andor-time-from-character-string/Wed, 24 Jul 2019 08:24:30 GMT