datetim and smalldatetime类型的插入:insert 表(日期字段)values(getdate())
or
insert 表(日期字段)values('2002-03-31')
OR:
insert 表(日期字段)values('2002-03-31 20:35:59')timestamp类型的字段系统自己维护,你不能插入任何值。

解决方案 »

  1.   

    通过
    DateTime.Parse(string s);
    将string类型的日期解析成datetime型
      

  2.   

    我的日期值保存在文件中,插入的时候从文件中读到SQL_TIMESTAMP_STRUCT结构中。
    插入时用
       char *pSql="INSERT INTO time VALUES(?)";
       SQL_TIMESTAMP_STRUCT Time;
       retcode = SQLPrepare(hstmt,(unsigned char*)pSql,SQL_NTS);
       retcode=SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,              SQL_C_TIMESTAMP,SQL_TIMESTAMP,16,0,
                                    &Time,0,(long*)len);
       从文件中读出时间存放在SQL_TIMESTAMP_STRUCT结构中   
       SQLExecute(hstmt);
    ----------------------------------------
    但是执行失败,绑订成功,执行失败---提示内存不可读!