标题:[求助][讨论]DATE函数返回的日期总是1905-6-3,让我百思不得其解
取消只看楼主
gogol
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2006-5-28
 问题点数:0 回复次数:1 
[求助][讨论]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

搜索更多相关主题的帖子: DATE函数 百思不得其解 SQL 数据库 CONN 
2006-06-21 22:53
gogol
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2006-5-28
得分:0 
就是在后面Str = "insert consumer values ('" & Text1.Text & "'," & Val(Trim(Text2.Text)) & ",'" & Trim(Text3.Text) & "'," & Date & ",'" & Combo1.Text & "','" & Combo2.Text & "','" & _ Combo3.Text & "','0')"这一句中的啊,现在我插入的记录又全变成 1900-1-1 了,真是郁闷啊!!!
2006-06-22 10:19



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-73982-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.172264 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved