T
thorax
[Originally posted in Sybase newsgroups but received no response.]
I'm having trouble passing a .NET DateTime value to a stored procedure
(parameter type datetime). Regardless of how the value is specified, it
seems to get truncated so the stored procedure receives the wrong value.
Below is the code which creates the columns on the untyped dataset,
where the values are being set and finally the values that finally make
it to ASA. (I'm running SA 9.02 + EBF 3302 on XP SP2.
Can anyone point me to what I'm doing wrong? Thanks in advance for any
help.
Steve.
1) Columns are added to untyped dataset:
pCol = pTable->Columns->Add(S"created_date", __typeof
(System:ateTime));
pCol = pTable->Columns->Add(S"modified_date", __typeof
(System:ateTime));
2) Sample code setting values for fields:
CTime ctNow(2006, 10, 26, 11, 12, 13);
DateTime dtNow(2006, 10, 26, 11, 12, 13);
s = ctNow.Format("%Y-%m-%d %H:%M:%S");
pRow->Item[S"created_date"] = s;
pRow->Item[S"modified_date"] = __box(dtNow);
3) Values as seen in debugger
s = 2006-10-26 11:12:13
__box(dtNow) = 26/10/2006 11:12:13
4) Code updating database:
bRetVal = m_pDatasetsAdapter->Update(pTable);
Value as displayed in ASA SQL log (-zr all):
10/26 10:22:01.810 ** HOSTVAR conn: 4 5 varchar '2006-10-'
<---- VALUE IS TRUNCATED
10/26 10:22:01.810 ** HOSTVAR conn: 4 6 varchar '2006-10-'
<---- VALUE IS TRUNCATED
I'm having trouble passing a .NET DateTime value to a stored procedure
(parameter type datetime). Regardless of how the value is specified, it
seems to get truncated so the stored procedure receives the wrong value.
Below is the code which creates the columns on the untyped dataset,
where the values are being set and finally the values that finally make
it to ASA. (I'm running SA 9.02 + EBF 3302 on XP SP2.
Can anyone point me to what I'm doing wrong? Thanks in advance for any
help.
Steve.
1) Columns are added to untyped dataset:
pCol = pTable->Columns->Add(S"created_date", __typeof
(System:ateTime));
pCol = pTable->Columns->Add(S"modified_date", __typeof
(System:ateTime));
2) Sample code setting values for fields:
CTime ctNow(2006, 10, 26, 11, 12, 13);
DateTime dtNow(2006, 10, 26, 11, 12, 13);
s = ctNow.Format("%Y-%m-%d %H:%M:%S");
pRow->Item[S"created_date"] = s;
pRow->Item[S"modified_date"] = __box(dtNow);
3) Values as seen in debugger
s = 2006-10-26 11:12:13
__box(dtNow) = 26/10/2006 11:12:13
4) Code updating database:
bRetVal = m_pDatasetsAdapter->Update(pTable);
Value as displayed in ASA SQL log (-zr all):
10/26 10:22:01.810 ** HOSTVAR conn: 4 5 varchar '2006-10-'
<---- VALUE IS TRUNCATED
10/26 10:22:01.810 ** HOSTVAR conn: 4 6 varchar '2006-10-'
<---- VALUE IS TRUNCATED