Access怎么写查询语句显示在DataGrid中
ACCESS 问题
在:家庭收入(编号,收入说明 ,收入金额 ,年, 月, 日 ,收入者)
这个表中(已经有了)。
查询编号(如1~100)如果我想查询 (20~30)
最后显示在:控件 DataGrid 所在的表格中。
我已经有一些语句:
Private Sub Command1_Click()
If Text1.Text = "" Or Text2.Text = "" Then
MsgBox "请写编号", vbOKOnly + vbExclamation, ""
Else
If Not IsNumeric(Text1.Text) Or Not IsNumeric(Text2.Text) Then
Text1.Text = ""
Text2.Text = ""
Else
sql = "select 家庭收入.编号, 家庭收入.收入说明 ,家庭收入.收入金额 ,家庭收入.年, 家庭收入.月,
家庭收入.日 ,家庭收入.收入者 from 家庭收入 where 编号 in (select 编号 from 家庭收入 where 编
号 >" + Text1.Text + " and 编号 <" + Text2.Text + ")"
re.Open sql, cn, adOpenDynamic, adLockOptimistic
关键我是想显示在:控件 DataGrid 所在的表格中。
请问还怎么写或者怎么设置?
我显示不出来,而且出错,主要是数据库错误。
请问到底怎么连接?