aakici
Posts: 49
|
| Posted: 05/22/2005, 6:20 PM |
|
I have a record form. I save values with a button. When i click this button a custom sql is executed. Everything is okay except date fields. Date fields are recorded as 0000-00-00. I couldn't solve this problem. Any comments?
_________________
Regards,
M.Alpaslan AKICI |
 |
 |
Nicole
Posts: 586
|
| Posted: 05/23/2005, 4:58 AM |
|
Hello,
Most probably you specified incorrect format for this date and so default empty date value is stored in a table. Make sure that date is passed to a database in format accepted by your database.
_________________
Regards,
Nicole |
 |
 |
aakici
Posts: 49
|
| Posted: 05/23/2005, 8:42 AM |
|
Thanks Nicole. However, this is a general problem for me. In fact, the problem is caused by custom SQL. The date textbox has correct format and default value for this textbox is today's date. but, all of these assigments not working. when page is loaded no default value is assigned, when submitting form date fields are recorded as 0000-00-00
_________________
Regards,
M.Alpaslan AKICI |
 |
 |
Nicole
Posts: 586
|
| Posted: 05/24/2005, 1:58 AM |
|
So the problem is default date is not displayed in a TextBox when page is loading. How exactly do you assigned a default value to the textbox?
Also what code do you use to execute custom query? Can you provide it?
_________________
Regards,
Nicole |
 |
 |
aakici
Posts: 49
|
| Posted: 05/24/2005, 1:35 PM |
|
Of course. Default value is assigned by CCS. ( I mean in the properties of textbox Default Value is Current Date). Used code is:
//*******************************************
global $stok;
global $DBDCesp;
$SQL = "UPDATE stokdetay SET "
. "satistar=" . CCToSQL($stok->starih->GetValue(), $stok->starih->DataType) . ", "
. "satisfatno=" . CCToSQL($stok->sbelgeno->GetValue(), ccsText) . ", "
. "satisfirmaid=" . CCToSQL($stok->sfirmaid->GetValue(), ccsInteger) . ", "
. "garantisuresi=" . CCToSQL($stok->gsuresi->GetValue(), ccsInteger) . ", "
. "satisfirmaadi=" . CCToSQL($stok->sfirma->GetValue(), ccsText) . " "
. "WHERE serino=" . CCToSQL($stok->serino->GetValue(), ccsText);
$db = new clsDBDCesp();
$db->query($SQL);
unset($db);
//*******************************************
I looked for my error and i think that this problem may be caused by 2 errors.
1. If i use CCS to build page, some extra codes are added. This sets date format.
2. I must use a code that sets dateformat to mysql.
But, i don't know what to do.
_________________
Regards,
M.Alpaslan AKICI |
 |
 |
aakici
Posts: 49
|
| Posted: 05/24/2005, 1:36 PM |
|
At the code above, date field is starih.
_________________
Regards,
M.Alpaslan AKICI |
 |
 |
Nicole
Posts: 586
|
| Posted: 05/25/2005, 4:47 AM |
|
Hello,
As I know it is preferably to use ToSQL() function of Connection class, rather than CCToSQL. In this case date is converted to date format specified in Connection dialog/Server settings.
...
global $DBDCesp;
$SQL = "UPDATE stokdetay SET "
. "satistar=" . $DBDCesp->ToSQL($stok->starih->GetValue(), ccsDate) . ", "
...
_________________
Regards,
Nicole |
 |
 |
aakici
Posts: 49
|
| Posted: 05/26/2005, 2:46 PM |
|
Yes Nicole. You are right. Your code is working. Thanks a lot.
_________________
Regards,
M.Alpaslan AKICI |
 |
 |
|