[求助][讨论]DATE函数返回的日期总是1905-6-3,让我百思不得其解
DATE函数返回的日期总是1905-6-3,让我百思不得其解对您的关注感激不尽!!
我在数据库中插入一条新纪录时,DATE函数返回的日期总是1905-6-3,让我百思不得其解,请各位帮忙看看哪里有误!谢谢! 数据库为gogol,表名为consumber,以下是代码:
dim CONN As New ADODB.Connection
dim RS As New ADODB.Recordset
CONN.ConnectionString = "Driver={SQL Server};Server=PR-MSI3R6ZOGP7A;uid=sa;pwd=;database=gogol"
CONN.Open
Private Sub CmdSave1_Click()
If Text1.Text = "" Then
MsgBox "人员姓名不能为空!", vbCritical + vbOKOnly, "数据保存错误"
Text1.SetFocus
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "编号不能为空!", vbCritical + vbOKOnly, "数据保存错误"
Text2.SetFocus
Exit Sub
End If
If Text2.Text <> "" Then
Str = "select * from consumer where number=" & Val(Trim(Text2.Text))
If Search(Str) = True Then
If RS.RecordCount > 0 Then
MsgBox "该编号已存在!", vbCritical + vbOKOnly, "数据保存错误"
Text2.SetFocus
Exit Sub
End If
End If
End If
If Text3.Text = "" Then
MsgBox "初始密码不能为空!", vbCritical + vbOKOnly, "数据保存错误"
Text3.SetFocus
Exit Sub
End If
Str = "insert consumer values ('" & Text1.Text & "'," & Val(Trim(Text2.Text)) & ",'" & Trim(Text3.Text) & "'," & Date & ",'" & _
Combo1.Text & "','" & Combo2.Text & "','" & Combo3.Text & "','0')"
CONN.Execute Str '如果这里用 RS.Open Str, CONN, adOpenKeyset, adLockPessimistic, -1 又总是报错“对象打开或关闭时无法操作”,请问为什么?关于RS 打开或关闭的情况能否给些见识?
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Combo1.Text = ""
Combo2.Text = ""
Combo3.Text = ""
End Sub