A bug when I synchronize data.

Jun 9, 2009 at 9:34 AM
Edited Jun 9, 2009 at 9:51 AM

below is my configuration:

    <List Site="projects/tmm10" Name="Parts Schedule" ActivationOrder="1">
        <Fields>
            <Field Name="Part Identifiers" SqlType="varchar(255)" SPType="Text" Required="true" />
            <Field Name="UC > China" SqlType="DateTime" SPType="date" Required="false" />
        </Fields>
    </List>
    <List Site="projects/tmm10" Name="UISchedule" ActivationOrder="1">
        <Fields>
            <Field Name="Part Name" SPType="Lookup" AssociatedList="Parts Schedule" AssociationName="UIScheduleToPartsSchedule" />
            <Field Name="UI > Ergonomist Superivor" SqlType="DateTime" SPType="date" Required="false" />
            <Field Name="UI > Validation Team" SqlType="DateTime" SPType="date" Required="false" />
            <Field Name="UI > Next Sub-process" SqlType="DateTime" SPType="date" Required="false" />
        </Fields>
    </List>

I receive the following error when I push Synchronize button:

System.FormatException: String was not recognized as a valid DateTime. at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) at AWS.SLAM.Data.SqlDataRepository.UpdateItem(String tableSchema, String tableName, String id, Hashtable values) at AWS.SLAM.Data.SqlDataServices.Update(String typeName, String id, Hashtable values) at AWS.SLAM.Events.ListItemUpdater.Update(SPListItem listItem) 

When SPType of field is date, and Required attribute is false, the value of field is empty in Sharepoint, then, those data cannot synchronize into SQL Server.

Example: I have 133 rows in the list named Parts Schedule. 29 records is synchronized success that the "UC > China" field has correct value (likes "1/12/2009") in Parts Schedule, but others is failure.

In AWS.SLAM.Data.SqlDataRepository.InsertItem(string tableSchema, string tableName, Hashtable values) and AWS.SLAM.Data.SqlDataRepository.UpdateItem(string tableSchema, string tableName, string id, Hashtable values)

code is:
                    else if (column.DataType.Contains("date"))
                    {
                        format = "[{0}] = convert(datetime, '{1}', 101),";
                        DateTime localizedDate = DateTime.Parse(columnValue);
                        columnValue = localizedDate.ToString("MM/dd/yyyy HH:mm:ss");
                    }
                    else if (String.IsNullOrEmpty(columnValue))
                    {
                        columnValue = "null";
                    }

Whether it should:
                    else if (String.IsNullOrEmpty(columnValue))
                    {
                        columnValue = "null";
                    }
                    else if (column.DataType.Contains("date"))
                    {
                        format = "[{0}] = convert(datetime, '{1}', 101),";
                        DateTime localizedDate = DateTime.Parse(columnValue);
                        columnValue = localizedDate.ToString("MM/dd/yyyy HH:mm:ss");
                    }

 

Developer
Jun 9, 2009 at 2:58 PM
Edited Jun 9, 2009 at 5:16 PM

This seems right, I am surprised I have not encountered it.

I have updated the downloads for the current Release, the version should say 1.2.0.4.

 

Thanks for bringing it our attention,

-Brian