Feedback
Did this article resolve your question/issue?

   

Article

Conversion failed when converting date and/or time from character string

« Go Back

Information

 
TitleConversion failed when converting date and/or time from character string
URL Name6892
Article Number000124125
EnvironmentProduct : Connect for ODBC SQL Server Native Wire Protocol driver
Version : 6.0
OS : Windows
Database : SQL Server
Application : ODBC Test Unicode
Question/Problem Description
The mentioned error message is returned when executing a parameterized insert statement in a Unicode application.
The ANSI value is bound as SQL_VARCHAR to insert in a Datatime2 field.
Steps to Reproduce
Clarifying Information
Table DDL :
create table svn_datetime2 (col1 int, col2 datetime2) 

Steps to Reproduce:
  • Start odbctest for unicode and connect to SQLServer 2008.
  • SQLPrepare ( "insert into svn_datetime2 values (1, ?) " )
  • SQLBindParameter( ParameterNumber = 1, SQL_PARAM_INPUT=1, ValueType = SQL_C_CHAR=1, ParameterType = SQL_VARCHAR=12, ColumnSize = 128, DecimalDigits = 0, ParameterValuePtr = "1900-01-01 02:03:04.123456", BufferLength = 128, StrLen_or_IndPtr = SQL_NTS=-3, SQL_LEN_DATA_AT_EXEC = FALSE, Buffer Size = 1998 )
  • SQLExecute ()
Return:
SQL_ERROR=-1
[DataDirect][ODBC SQL Server Native Wire Protocol driver][Microsoft SQL Server]Conversion failed when converting date and/or time from character string."
Error Message[DataDirect][ODBC SQL Server Native Wire Protocol driver][Microsoft SQL Server]Conversion failed when converting date and/or time from character string.
Defect NumberDefect DD00053392 / PSC00047189
Enhancement Number
Cause
The problem is caused by an application error. ODBC Test Unicode is sending UCS-2 string parameters to the driver when the C Type is SQL_C_CHAR. When the C Type is SQL_C_CHAR, the data should be in an ANSI character set and not UCS-2.  When UCS-2 is used for the character set of the data, the application should use the SQL_C_WCHAR data type.
Resolution
This is an application issue.
Workaround
Notes
Defect DD00053392 has been rejected as this is an application issue.
Last Modified Date10/29/2015 12:01 PM
Files
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.