代码如下 Dim i as integer, dd As Date Dim strConn As String Dim pubConn As New ADODB.Connection Dim rsTable As New ADODB.Recordset Dim strSQL As String strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=up4u.mdb;Persist Security Info=False" pubConn.Open strConn rsTable.CursorLocation = adUseClient If Not TableIsIn(pubConn, "hello") Then strSQL = "SELECT * into hello FROM TEMPLATE WHERE 1<>1" rsTable.Open strSQL, pubConn, adOpenDynamic, adLockOptimistic rsTable.Close End If i=1 dd = Now() strSQL = "INSERT INTO hello(TIME) VALUES (#" & dd & "#)" pubConn.Execute strSQL 到这一句就显示syntax error in INSERT INTO statement 我知道是日期时间类型的转换不对,因为如果我把strSQL=...句里的#号去掉,换dd成为i就可以加进数据库。 请问,如何能把日期时间型数据加入数据库。rsTable.addnew那个方法我会,但是那个方法似乎用来修改纪录不方便,所以想研究用sql的方法。 先谢谢了 |