3
3cat
Unregistered / Unconfirmed
GUEST, unregistred user!
想把Date存成2000-02-03的格式,连MySQL总是说操作不可进行
但是连Oracle或SQL Server存储Date没问题,代码如下
(是C++Builder的,但道理应是一样的):
ClientDataSet1->Close();
ClientDataSet1->Params->Clear();
ClientDataSet1->CommandText = "insert into drive(ID,Birthday) valuesID,:Birthday)";
ClientDataSet1->Params->CreateParam (ftInteger,"ID",ptInput);
ClientDataSet1->Params->CreateParam (ftDate,"Birthday",ptInput);
ClientDataSet1->Params->Items[0]->Value = StrToInt(EdtID->Text );
DateSeparator = '-';
ShortDateFormat = "yyyy-mm-dd";
ClientDataSet1->Params->Items[1]->Value = StrToDate(EdtBirthday->Text) ;
或者ClientDataSet1->Params->Items[1]->Value = FormatDateTime("yyyy-mm-dd", StrToDate(EdtBirthday->Text))
ClientDataSet1->Execute();
是不是MYSQL要设置什么,请帮帮忙,谢谢
但是连Oracle或SQL Server存储Date没问题,代码如下
(是C++Builder的,但道理应是一样的):
ClientDataSet1->Close();
ClientDataSet1->Params->Clear();
ClientDataSet1->CommandText = "insert into drive(ID,Birthday) valuesID,:Birthday)";
ClientDataSet1->Params->CreateParam (ftInteger,"ID",ptInput);
ClientDataSet1->Params->CreateParam (ftDate,"Birthday",ptInput);
ClientDataSet1->Params->Items[0]->Value = StrToInt(EdtID->Text );
DateSeparator = '-';
ShortDateFormat = "yyyy-mm-dd";
ClientDataSet1->Params->Items[1]->Value = StrToDate(EdtBirthday->Text) ;
或者ClientDataSet1->Params->Items[1]->Value = FormatDateTime("yyyy-mm-dd", StrToDate(EdtBirthday->Text))
ClientDataSet1->Execute();
是不是MYSQL要设置什么,请帮帮忙,谢谢