Tuesday, August 2, 2011

Date Insert In MySQL using .NET

To insert date object using C#.net in MySQL db,use the code below:
Code:
1:  string query = String.Format("Insert into tbllistings(DateRegistered)"  
2:   + "values(DATE_FORMAT({0}, '%Y-%m-%d %h:%m:%s'))",objJobs.DateRegistered); 
The key to the solution is using the MySQL Date format function.

0 comments:

Post a Comment