麻烦问一下关于datagrid的问题
我有一段查询数据库的程序,要将符合条件的记录用datagrid显示出来。可是用datagrid要用到adodc,我用了两个窗体,一个输入条件,名为conre,一个显示datagrid,名为require。我写了如下代码,想用conre的输入条件控制require中adodc1的数据源recordsouce。require的adodc1的属性里填了connectionstring,recordsouce没填。conre的代码如下:
Private Sub Command1_Click()
If Combo1.Text = "请输入字段" Or Text1.Text = "" Then
inta = 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 & Combo2.Text _
& "'" & Text1.Text & "'"
End If
require.Show
Combo1.Text = "请选择字段"
Text1.Text = ""
End Sub
Private Sub Form_Load()
Combo1.AddItem "number"
Combo1.AddItem "name"
Combo1.AddItem "date"
Combo1.AddItem "provider"
Combo1.AddItem "stock_place"
Combo1.AddItem "note"
Combo2.AddItem "="
Combo2.AddItem "like"
End Sub
可是运行后发生错误,显示:[adodc]:没有指定纪录源。[ado]没有为命令对象设置命令。
我也曾尝试用ado对象,用查询条件生成记录集rs,但rs怎么和adodc1联系上?
麻烦高手指点!