是的,我在家用的是: strSql="insert into sms_cmpp (serviceid,content,mobilecode,sendtime) SELECT 1,a.content,b.mobilecode,now() FROM biz_huicai_cmpp a, users_cmpp b where a.id=" & msgid & " and b.yewuid=22 and b.mobilecode is not null" 可以在ACCESS做得,可是今天来到公司,公司用的是sql,程序没有变,但是没有插进去,在查询分析器里提示Now()不识,只好修改为GETDATE() 函数,不知道是环境变了还是什么原因!
SQL Server内部时间函数为Getdate(),而Access内部时间函数为Now()。
那 strSql="insert into sms_cmpp (serviceid,content,mobilecode,sendtime) SELECT 1,a.content,b.mobilecode,now() FROM biz_huicai_cmpp a, users_cmpp b where a.id=" & msgid & " and b.yewuid=22 and b.mobilecode is not null" 修改sql,的这个函数,还要修改其他的吗?
SELECT '1' --試一下
楼上不是说了吗!~ SQL Server内部时间函数为Getdate(),而Access内部时间函数为Now()。你既然是SQL Server也不用将strSql="insert into sms_cmpp (serviceid,content,mobilecode,sendtime) SELECT 1,a.content,b.mobilecode,now() FROM biz_huicai_cmpp a, users_cmpp b where a.id=" & msgid & " and b.yewuid=22 and b.mobilecode is not null"里的getdate()改成now()啊~ 楼主应该说说你到有没有报错,报错了是什么错误~
刚测试了很多次,出现怪问题:insert into sms_cmpp (serviceid,content,mobilecode,sendtime) SELECT '1'as serviceid,a.content,b.mobilecode,GETDATE()as sendtime FROM biz_huicai_cmpp a, users_cmpp b where a.id=4 and b.yewuid=22 and b.mobilecode is not null 在查询分析器里运行后,在对应的表里运行,现实如下结果 6239 1 13806007150 666666 2006-6-6 13:41:30 但当关掉表再打开或再运行表时就消失了,这个我就搞不懂了,不知道怎么办!
用 strSql="insert into sms_cmpp (serviceid,content,mobilecode) SELECT 1,a.content,b.mobilecode FROM biz_huicai_cmpp a, users_cmpp b where a.id=" & msgid & " and b.yewuid=22 and b.mobilecode is not null" 就能插入数据,但是就是不能插入当前时间!
是追加在SQL Server表中!但用strSql="insert into sms_cmpp (serviceid,content,mobilecode,sendtime) SELECT 1 as serviceid,a.content,b.mobilecode,GETDATE() FROM biz_huicai_cmpp a, users_cmpp b where a.id=" & msgid & " and b.yewuid=22 and b.mobilecode is not null"就插不进去了,只有在查询分析器里执行(先分析查询,在执行查询的顺序,直接用执行查询就不行!),并打开对应的表刷新的时候才出现数据,在刷新就没了!
只读,且当前数据记录只能向下移动ADOPENKEYSET(=1)
只读,当前数据记录可自由移动ADOPENDYNAMIC(=2)
可读写,当前数据记录可自由移动ADOPENSTATIC(=3)
可读写,当前数据记录可自由移动,可看到新增记录
B:ADLOCKREADONLY(=1)
缺省锁定类型,记录集是只读的,不能修改记录ADLOCKPESSIMISTIC(=2)
悲观锁定,当修改记录时,数据提供者将尝试锁定记录以确保成功地编辑记录。只要编辑一开始,则立即锁住记录。ADLOCKOPTIMISTIC(=3)
乐观锁定 ,直到用Update方法提交更新记录时才锁定记录。ADLOCKBATCHOPTIMISTIC(=4)
批量乐观锁定,允许修改多个记录,只有调用UpdateBatch方法后才锁定记录。当不需要改动任何记录时,应该使用只读的记录集,这样提供者不用做任何检测。对于一般的使用,乐观的锁定可能是最好的选择,因为记录只被锁定一小段时间,数据在这段时间被更新。这减少了资源的使用。
GETDATE() 函数在ACCESS里可以执行?怎么可能~
可以在ACCESS做得,可是今天来到公司,公司用的是sql,程序没有变,但是没有插进去,在查询分析器里提示Now()不识,只好修改为GETDATE() 函数,不知道是环境变了还是什么原因!
修改sql,的这个函数,还要修改其他的吗?
SQL Server内部时间函数为Getdate(),而Access内部时间函数为Now()。你既然是SQL Server也不用将strSql="insert into sms_cmpp (serviceid,content,mobilecode,sendtime) SELECT 1,a.content,b.mobilecode,now() FROM biz_huicai_cmpp a, users_cmpp b where a.id=" & msgid & " and b.yewuid=22 and b.mobilecode is not null"里的getdate()改成now()啊~
楼主应该说说你到有没有报错,报错了是什么错误~
SELECT '1'as serviceid,a.content,b.mobilecode,GETDATE()as sendtime FROM biz_huicai_cmpp a, users_cmpp b where a.id=4 and b.yewuid=22 and b.mobilecode is not null
在查询分析器里运行后,在对应的表里运行,现实如下结果
6239 1 13806007150 666666 2006-6-6 13:41:30
但当关掉表再打开或再运行表时就消失了,这个我就搞不懂了,不知道怎么办!
就能插入数据,但是就是不能插入当前时间!
如果是Access的表中,用Now()。