Private Sub Command1_Click()
Dim pStatus As String
Dim a As String
a = Trim(Text1.Text)
Dim b As String
b = Trim(Text2.Text)
Dim c As String
c = Trim(Text3.Text)
Dim padoConnection As New ADODB.Connection
With padoConnection
.ConnectionString = "provider=microsoft.jet.oledb.4.0;persist security info=false;data source=" & App.Path & "\物品领用登记表.mdb"
.Open
If .State = adStateOpen Then
pStatus = "Connection is OK!"
Else
pStatus = "Connection is Failed!"
End If
End With
With Adodc1
.ConnectionString = padoConnection
.RecordSource = "select * from 物品领用登记表 where 领用人姓名 LIKE '%" + a + "%' and 物品名称 LIKE '%" + b + "%' and 数量 like '%" + c + "%'" + " and 领用日期 between '" + Text4.Text + "' and '" + Text5.Text + "'"
.LockType = adLockOptimistic
End With
Adodc1.Refresh
DoEvents
DataGrid1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
我是初学者,在做个报表查询时遇见这样的一个问题.
运行提示:对象"refresh" 的方法" IAdodc"失败,请问是什么原因?该怎么改正.
Dim pStatus As String
Dim a As String
a = Trim(Text1.Text)
Dim b As String
b = Trim(Text2.Text)
Dim c As String
c = Trim(Text3.Text)
Dim padoConnection As New ADODB.Connection
With padoConnection
.ConnectionString = "provider=microsoft.jet.oledb.4.0;persist security info=false;data source=" & App.Path & "\物品领用登记表.mdb"
.Open
If .State = adStateOpen Then
pStatus = "Connection is OK!"
Else
pStatus = "Connection is Failed!"
End If
End With
With Adodc1
.ConnectionString = padoConnection
.RecordSource = "select * from 物品领用登记表 where 领用人姓名 LIKE '%" + a + "%' and 物品名称 LIKE '%" + b + "%' and 数量 like '%" + c + "%'" + " and 领用日期 between '" + Text4.Text + "' and '" + Text5.Text + "'"
.LockType = adLockOptimistic
End With
Adodc1.Refresh
DoEvents
DataGrid1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
我是初学者,在做个报表查询时遇见这样的一个问题.
运行提示:对象"refresh" 的方法" IAdodc"失败,请问是什么原因?该怎么改正.
用eof和bof判断一下,没有记录就不刷新,不然会出错
Set DataGrid1.DataSource = Adodc1
这两句反过来
Adodc1.ConnectionString = SQLConntectString
Adodc1.RecordSource = "Select idno,Name,defaultvalue from Charge where Idno > 2"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
还有你的“物品领用登记表”是数据库还是数据表?
语句。这个却显示全部,不能根据条件来查询。这个语句是万能查询,输入为空表示全部,逐个条件输入也可以。该怎么解决,请大家帮忙啊!在线等待,谢谢大虾!
============
select * from 物品领用登记表 ??
============
到底是数据库还是表?