想在VB中实现对表的查询
代码该怎么写??
Private Sub Command1_Click()
If Check1.Value = 1 Then
Adodc1.Recordset.Find "student_ID='" & Trim(Text1.Text) & "'"
DataGrid1.Refresh
Set DataGrid1.DataSource = Adodc1
End If
End Sub
这样写可以实现查询的功能
可是,只是光标移到该记录上而已,如图:
要怎么样才能使dataGrid里只显示该记录呢
[此贴子已经被作者于2006-11-30 23:08:12编辑过]
谢谢版主,可是还是不会写
Private Sub Command1_Click()
With Adodc1
.RecordSource = "SELECT * FROM student_Info"
.Refresh
End With
Set DataGrid1.DataSource=Adodc1
End Sub
这样写,它老是提示对象打开时出错,还有也提示Refresh有错
Private Sub Command1_Click()
If Check1.Value = 1 Then
Adodc1.Refresh
Adodc1.Recordset.RecordSource = "select student_Name,student_Gender,....from student_Info where student_ID='" & Trim(Text1.Text) & "'"
Set DataGrid1.DataSource = Adodc1
End If
End Sub
这样写,也提示一样的错误,那到底要怎么写呢
还有如果是按班级查询,一个班里面有多条记录,用Filter来做,DataGrid只显示原来的数据,查询根本没有反应.
如果用Select语句,又该怎么写,怎么让所查的记录集在DataGrid里显示出来呢
没学过VB啊,弄出错误一堆一堆的,大家帮帮忙啊,异常感谢啊