I am having issues inserting a record to a date field in Salesforce
This is the error I get: "You have an error in your SQL syntax at line 5, column 15: ')' expected
I tried with out the time option but it gives me an "Unsupported expression type Binary
See Example
insert into Opportunity (AccountId,Name,StageName,CloseDate,Type,OwnerId,Is_Coverage_currently_in_place) values
( '00130000011CQb5AAG',
'Prospect test',
'Prospect',
7/31/2014 12:00:00 AM,
'New Business',
'00530000007lHuBAAU',
'No' )
RETURNING Id
Unable insert records to a Date fields
Re: Unable insert records to a Date fields
1. You should quote with a single quote (') the date specified in the query text.
2. The format of the date depends on a default format for dates of your Visual Studio's language. For example: the value should be '2014-07-31 12:00:00' in my test code.
3. You can also use parameters when employing date columns in the query:
2. The format of the date depends on a default format for dates of your Visual Studio's language. For example: the value should be '2014-07-31 12:00:00' in my test code.
3. You can also use parameters when employing date columns in the query:
Code: Select all
SalesforceCommand cmd = conn.CreateCommand();
cmd.CommandText = @"insert into Opportunity (AccountId,Name,StageName,CloseDate, ...) values
( '00130000011CQb5AAG',
'Prospect test',
'Prospect',
:myparam, ...";
cmd.Parameters.Add("myparam", SalesforceType.DateTime).Value = new DateTime(2013, 07, 01, 12, 0, 0);
cmd.ExecuteNonQuery();