Sqlite:如何从C绑定和插入日期?
发布时间:2020-12-12 18:55:54 所属栏目:百科 来源:网络整理
导读:使用C(Visual Studio)和sqlite.如何将日期绑定到参数? sqlite3_stmt *statement;const char *sql = "INSERT INTO employees " "(full_name," "date_started)" " VALUES " "(@full_name," "@date_started)";sqlite3_prepare_v2(database_,sql,-1,statement,N
使用C(Visual Studio)和sqlite.如何将日期绑定到参数?
sqlite3_stmt *statement; const char *sql = "INSERT INTO employees " "(full_name," "date_started)" " VALUES " "(@full_name," "@date_started)"; sqlite3_prepare_v2(database_,sql,-1,&statement,NULL); int parameterIndex = sqlite3_bind_parameter_index(statement,"@full_name"); sqlite3_bind_text(statement,parameterIndex,"John Smith",SQLITE_TRANSIENT); parameterIndex = sqlite3_bind_parameter_index(statement,"@date_started"); // <??? what goes here ???> // I want to include the local current time,so I want to know: // 1. what's the best way to get local time in C++ // 2. and what goes here for the date binding sqlite3_step(statement); sqlite3_finalize(statement); 注意:我不想使用sql设置当前时间(例如,CURRENT_TIMESTAMP等) 解决方法它没有诀窍:const char * sql = "INSERT INTO Employees(full_name,data_started) VALUES (?,?)"; time_t time = 0x3DE43B0C; sqlite3_bind_int64(statement,2,time); 以下是documentation的相关部分:
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读