Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

toDatetime.

$
0
0

 Hi everyone!

 I'am working with DATE fields inside SQL Server. When I try to save values from my web form, look what's happen:

 First tried, I did not use the ' '...

1. 1/1/1901

 Error = [1] - Incorrect syntax near '/'.

 Second, I use the ' '...

2. '1/1/1901'

  Error =

Server Error in '/WebAppCAE' 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 59:             base.vincularControleObjeto(container);
Line 60:             this.regJuntaCartorio = ((TextBox)container.FindControl("regJuntaCartorio")).Text;
Line 61:             this.dataRegJuntaCartorio = Convert.ToDateTime(((TextBox)container.FindControl("dataRegJuntaCartorio")).Text);
Line 62:         }
Line 63:
 

Source File: C:\(Projeto)\Fonte\CAE\PessoaJuridica.cs    Line: 61


 The field is dataRegJuntaCartorio and I used the ToDateTime to convert it to my object before I save it to the database.

 How should I use datetime fields inside C#? Any examples?

 Thanks,

Doria


Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>