Private Sub Command1_Click() Adodc_index.RecordSource = "select * from table1 where ID = '1000022'" Adodc_index.Refresh DataGrid1.Refresh End Sub
adodc1.refresh 改变其数据源
Adodc_index.recordset.open = "select * from table1 where ID = '1000022'"set datagrid.datasource=adodc_index.recordset
Set rsInspection = New ADODB.Recordset With rsInspection .CursorType = adOpenStatic .CursorLocation = adUseClient .LockType = adLockPessimistic .Source = "SELECT * FROM tblpropertyspec WHERE property ='" & adoProperty.Recordset.Fields("property") & "'" Set .ActiveConnection = cnnCMMS .Open End With set dattagrid1.datasource=nothing Set DataGrid1.DataSource = rsInspection
strSQLCha = "select * from 销售表 where " & strFindID Rst2.Open strSQLCha, Cnn1, adOpenStatic, adLockPessimistic Set DataGrid1.DataSource = Rst2
如果用Adodc_index.Refresh则会出现“FROM子句出现错误”!这么回事????
Private Sub Command1_Click() Adodc_index.RecordSource = "select * from table1 where ID = '1000022'" Adodc_index.refresh set datagrid1.datasource=adodc_index.recordsource DataGrid1.Refresh End Sub
写错了 改正如下:Private Sub Command1_Click() Adodc_index.RecordSource = "select * from table1 where ID = '1000022'" Adodc_index.refresh set datagrid1.datasource=adodc_index.recordset DataGrid1.Refresh End Sub
= "select * from table1 where ID = 1000022"
原来必须是 abCmText 而不是 abCmTable 然后填写命令代码 select * from table1 where ID = 1000022
Adodc_index.RecordSource = "select * from table1 where ID = '1000022'"
Adodc_index.Refresh
DataGrid1.Refresh
End Sub
改变其数据源
With rsInspection
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.LockType = adLockPessimistic
.Source = "SELECT * FROM tblpropertyspec WHERE property ='" & adoProperty.Recordset.Fields("property") & "'"
Set .ActiveConnection = cnnCMMS
.Open
End With set dattagrid1.datasource=nothing
Set DataGrid1.DataSource = rsInspection
Rst2.Open strSQLCha, Cnn1, adOpenStatic, adLockPessimistic
Set DataGrid1.DataSource = Rst2
Adodc_index.RecordSource = "select * from table1 where ID = '1000022'"
Adodc_index.refresh
set datagrid1.datasource=adodc_index.recordsource
DataGrid1.Refresh
End Sub
改正如下:Private Sub Command1_Click()
Adodc_index.RecordSource = "select * from table1 where ID = '1000022'"
Adodc_index.refresh
set datagrid1.datasource=adodc_index.recordset
DataGrid1.Refresh
End Sub