Kbase P66624: The ODBC driver does not always correctly map an ODBC DateTime data type to a Progress character fie
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  2/23/2006 |
|
Status: Unverified
FACT(s) (Environment):
Progress 9.1D
Windows
SYMPTOM(s):
The ODBC driver does not always correctly map an ODBC DateTime data type to a Progress character field.
NullReferenceException when using Merant 3.60 driver to write data to Progress DB from Microsoft .NET (dotNET) application.
System.NullReferenceException: Object reference not set to an instance of an object. at System.Data.Common.Odbc32.SQLSetStmtAttrW
Reading the records after the previous failure will result in a FormatException.
FormatException: The string was not recognized as a valid DateTime.
Binding a parameter to a character column using OdbcType.DateTime.
CAUSE:
Progress version 9 and earlier do not have a DateTime data type.
FIX:
Bind the parameter to a character column by using OdbcType.NVarChar instead. The following Visual Basic and C# code snippets show the syntax of using the OdbcType property:
Visual Basic:
Dim nwindConn As OdbcConnection = New OdbcConnection("Driver={SQL Server};Server=localhost;" & _
"Trusted_Connection=yes;Database=northwind")
Dim custDA As OdbcDataAdapter = New OdbcDataAdapter
Dim selectCMD AS OdbcCommand = New OdbcCommand(selectSQL, nwindConn)
custDA.SelectCommand = selectCMD
' Add Parameters and set values.
selectCMD.Parameters.Add("@Country", OdbcType.VarChar, 15).Value = "UK"
selectCMD.Parameters.Add("@City", OdbcType.VarChar, 15).Value = "London"
Dim custDS As DataSet = New DataSet
custDA.Fill(custDS, "Customers")
C#:
OdbcConnection nwindConn = new OdbcConnection("Driver={SQL Server};Server=localhost;" +
"Trusted_Connection=yes;Database=northwind;");
OdbcDataAdapter custDA = new OdbcDataAdapter();
OdbcCommand selectCMD = new OdbcCommand(selectSQL, nwindConn);
custDA.SelectCommand = selectCMD;
//Add Parameters and set values.
selectCMD.Parameters.Add("@Country", OdbcType.VarChar, 15).Value = "UK";
selectCMD.Parameters.Add("@City", OdbcType.VarChar, 15).Value = "London";
DataSet custDS = new DataSet();
custDA.Fill(custDS, "Customers");