请教关于查询问题的两个错误
我的数据表叫ma,根据输入的字段值查询记录结果。下面是程序代码:
Option Explicit
Private Sub Command1_Click()
If Combo1.Text = "请输入字段" Or Text1.Text = "" Then
MsgBox "请输入字段名和字段值", 21, "错误"
Exit Sub
End If
If Combo1.Text = "date" Then
require.Adodc1.RecordSource = "select * from ma where [Date]=" & Text1.Text
Else
require.Adodc1.RecordSource = "select * from ma where " & Combo1.Text & "='" & Text1.Text & "'"
End If
require.Adodc1.Refresh
If require.Adodc1.Recordset.BOF And require.Adodc1.Recordset.EOF = True Then
MsgBox "没有此项记录!"
Else
require.Show
End If
Combo1.Text = "请选择字段"
Text1.Text = ""
End Sub
Private Sub Form_Load()
Combo1.AddItem "number"
Combo1.AddItem "name"
Combo1.AddItem "date"
Combo1.AddItem "provider"
Combo1.AddItem "stockplace"
Combo1.AddItem "note"
require. = adCmdText
require.Adodc1.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=fudan;Data Source=VM"
End Sub
1.运行后,输入"date" ,"2009-1-2"查询,显示:“没有此项记录!”
而在SQL数据库中,确实是有这一项的。不知问题出在哪里?
2.每一次查询后,数据库都会自动把查询到的记录的第一项的“number”字段清空,真是奇怪,不知道是什么问题?
3.不知:option explicit 是什么意思?
麻烦高手指教!
为了问这几个问题,我等了好几天了。网站出了什么问题?
[ 本帖最后由 冰雪清风 于 2009-11-29 19:12 编辑 ]