VB sql的2 个代码错误

来源:百度知道 编辑:UC知道 时间:2024/05/30 04:27:22
Private Sub Command2_Click()
Dim i As Integer
Adodc1.Refresh
If Adodc1.Recordset.State = 1 Then '选择读者所借书
Adodc1.Recordset.Close
End If
Adodc1.Recordset.Open "select * from 借阅信息表 where 应还书日期 < #" & Date & "#", "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=tushu"
Set DataGrid1.DataSource = Adodc1
Label3.Caption = "读者你好!图书馆当前的超期书数是" & Adodc1.Recordset.RecordCount & "本"
' MsgBox Adodc1.Recordset.RecordCount

End Sub

错误信息:

第一行 '#' 附近有语法错误

---------------------------------------
If CDate(Text16.Text) < Date Then
MsgBox "超期罚款"
' Text9.Enabled = True
' Text10.Enabled = True

你用的是什么数据库,##似乎只是Access的日期表示,其它大部分数据库的日期格式都和系统设置有关。SQLServer里,要想日期和系统格式无关,最好用:convert(datetime,'2008-5-12',120)这种方式转换

用 cdate('" +date +"')" 来代替#