自动清空自段?!求教!
我建了两个窗体,一个叫core,输入查询条件,一个叫require,用datagrid显示查询结果。以下是core窗体的代码(command1:确定):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
每一次查询后,数据库都会自动把查询到的记录的第一项的“number”字段清空,真是奇怪,不知道是什么问题?
请高手指教!