Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
karthi2009
Starting Member
23 Posts |
Posted - 2009-05-20 : 07:34:03
|
Hi,I am using SqlBulkCopy Class to import data from Excel File. Currently I am facing an issue with DateTime Type Column. Database Table Desc--------------------emp# int,empname varchar(100),timein datetime -- (required Date with Time)DataTable Columns Spec-----------------------emp# string,empname string,date string,time stringbefore importing the data, I merge date and time columns to match database table column named 'timein'. DateTime dTime = Convert.ToDateTime(date + " " + time);But when I try to execute it, I am getting an exception in WriteToServer() method. The exception I am getting is "System.FormatException: String was not recognized as a valid DateTime.". Please guide me out in this regard.Thanks in advance.Karthikeyan |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2009-05-20 : 07:46:55
|
moved from article discussion since this has nothing to do with articles.___________________________________________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.5 out! |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2009-05-20 : 07:48:06
|
your strings are not in a valid date time format. try using DateTime.TryParse instead.if that doesn't work, you'll have to clean the data in excel before importing.___________________________________________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.5 out! |
|
|
|
|
|