1. Kwadwo Boahene
  2. PowerBuilder
  3. Tuesday, 3 March 2020 16:06 PM UTC

Hi All,

        I am  in the process of PB conversion of an legacy application from db2 to sql server. I am having a problem with how sql srver handles dates in a datawindow. The below example in db2 returns the current datetime and saved in the datawindow with no problem. When I try the same thinh in sql sever I get blanks. What's causing this problem and any solution. PB 2017 and sql server 2016.

example:

datetime ldt_current
ldt_current = DateTime(Today(), Now())

dw_1.setitem(i,"a1",ldt_current)

 

Thanks,

Kwadwo

Accepted Answer
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 3 March 2020 19:54 PM UTC
  2. PowerBuilder
  3. # Permalink

Greetings, Kwadwo -

Can you please provide an example DW object (source) that is failing with SQL Server?

Regards, John

Comment
  1. Kwadwo Boahene
  2. Tuesday, 3 March 2020 20:12 PM UTC
if I getting you right the dw source ===> column=(type=char(26) update=yes updatewhereclause=yes name=rrrr dbname="a1" ) .

. it is the same db2 setup but i thought it work with no problem.

/////

-Connectstring='DSN=kkkk;UID=ppp;PWD=xxxx,StripParmNames='Yes',DateTimeFormat='\''yyyy-mm-dd hh:mm:ss.fff\'''

I just added the date format to see if it work. Connection is through odbc.
  1. Helpful
  1. John Fauss
  2. Tuesday, 3 March 2020 20:58 PM UTC
The column type in the DataWindow's column specifications for a datetime or smalldatetime column in a SQL Server table needs to be datetime, not char(26).
  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 4 March 2020 02:44 AM UTC
In other words, this has nothing to do with using either DB2 nor SqlServer
  1. Helpful
There are no comments made yet.
Kwadwo Boahene Accepted Answer Pending Moderation
  1. Wednesday, 4 March 2020 13:21 PM UTC
  2. PowerBuilder
  3. # 1

I tried both suggestions and they worked. I am going to change the source to datetime instead of char since that will be easier for me because there too many references to the dates elsewhere in the application.

Thanks to all.

Comment
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Tuesday, 3 March 2020 21:03 PM UTC
  2. PowerBuilder
  3. # 2

Hi Kwadwo,

Column in DataWindow's buffer is CHAR(26)  => You therefore MUST use

  • GetItemString(row, "a1") to obtain value - and - 
  • SetItem(row, "a1", <string-expression> ) to store new value in DW buffer

DateTime variable will ONLY work on columns having datatype = DATETIME or similar (naming sometimes depends on DBMS).

You may try:  dw.SetItem(row, "a1", String( DateTime( Today( ), Now( ) ) ) )

HTH /Michael

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.