Last post Apr 15, 2011 08:48 AM by Ganeshkar
May 19, 2010 03:35 AM|germaine.tay|LINK
I have this error "The given value of type String from the data source cannot be converted to type datetime of the specified target column." when I used sqlbulkcopy to do the transaction
Here is my code:
Dim id As String = gvData.DataKeys(gvr.RowIndex).Value.ToString
'compare with the id in DataTable or others
intRetValue = WebService.AddEvent(dtDataTable.Rows(gvr.RowIndex).Item("EventID").ToString(), dtDataTable.Rows(gvr.RowIndex).Item("startDate").ToString(), dtDataTable.Rows(gvr.RowIndex).Item("EndDate").ToString()))
my startDate and EndDate are of type datetime in the sql..
May 19, 2010 04:12 AM|adeelehsan|LINK
It seems that you are reading data from the DataTable and inserting to the database. What is the format of the data in startDate and endDate columns in Data Table? Make sure it is compatible with the default format of the SQL Server.
asp .net 2. 0
May 19, 2010 04:18 AM|Jalpesh P. Vadgama|LINK
I think the problem is that in data table you have datetime as string and you inserting that in date time in sql server.
Store date time format in data table and it will work.
May 20, 2010 04:03 AM|germaine.tay|LINK
Hi. So I have changed the data table to the following
DataRow("StartDate") = CType(Trim(reader("Date of Event").ToString), Date)
DataRow("EndDate") = CType(Trim(reader("Date of Event").ToString), Date)
Is it Date or DateTime? Are they the same?
In addition, may i know if say I have a string like this "29 Jul 2009 (Morning)" in the excel file, how do I extract the date out from this string and stored in the DataRow("StartDate") ?
Apr 15, 2011 08:48 AM|Ganeshkar|LINK
If the table having autonumber column, then u need to add a column (of type integer) to your Dataset or Datatable