Public adoCon As New ADODB.Connection Public adors As New ADODB.RecordsetPrivate Sub AlarmTime_Click() If AlarmTime.Value Then DataStart.Enabled = True DataEnd.Enabled = True Else DataStart.Enabled = False DataEnd.Enabled = False End If End SubPrivate Sub DeviceArea_Click() If DeviceArea.Value Then DeviceAreaTxt.Enabled = True Else DeviceAreaTxt.Enabled = False End If End SubPrivate Sub DeviceName_Click() If DeviceName.Value Then DeviceNameTxt.Enabled = True Else DeviceNameTxt.Enabled = False End If End SubPrivate Sub Form_Load() MainButton.Picture = MainUp.Picture SendButton.Picture = SendUp.Picture TransmissionButton.Picture = TransmissionUp.Picture DryingButton.Picture = DryingUp.Picture ReclaimButton.Picture = ReclaimUp.Picture AlarmButton.Picture = AlarmUp.Picture ExitButton.Picture = ExitUp.Picture DataGrid1.Visible = True Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\SKJ.mdb " & ";Persist Security Info=False" Adodc1.RecordSource = "select * from 报警记录 where 报警时间 > now" Adodc1.Refresh Frame2.Visible = False End SubPrivate Sub TabStrip1_Click() Select Case TabStrip1.SelectedItem.Index Case 1 DataGrid1.Visible = True DataGrid2.Visible = False DataGrid3.Visible = False DataGrid4.Visible = False DataGrid5.Visible = False DataGrid6.Visible = False DataGrid7.Visible = False Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\SKJ.mdb " & ";Persist Security Info=False" Adodc1.RecordSource = "select * from 报警记录 where 报警时间 > now" Frame2.Visible = False Case 4 DataGrid4.Visible = True DataGrid1.Visible = False DataGrid2.Visible = False DataGrid3.Visible = False DataGrid5.Visible = False DataGrid6.Visible = False DataGrid7.Visible = False Adodc4.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\SKJ.mdb " & ";Persist Security Info=False" Adodc4.RecordSource = "select * from 故障记录 where 故障时间 > now" Adodc4.Refresh Frame2.Visible = False Case 7 DataGrid7.Visible = True DataGrid1.Visible = False DataGrid2.Visible = False DataGrid3.Visible = False DataGrid4.Visible = False DataGrid5.Visible = False DataGrid6.Visible = False Adodc7.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\SKJ.mdb " & ";Persist Security Info=False" Adodc7.RecordSource = "select * from 系统日志" Adodc7.Refresh Frame2.Visible = False End Select End Sub'退出系统按钮的退出动作 Private Sub ExitButton_Click() SKJAlarm.Adodc7.Recordset.AddNew '将系统结束运行状态记录到系统日志 SKJAlarm.Adodc7.Recordset.Fields(0) = "系统停止" SKJAlarm.Adodc7.Recordset.Fields(1) = "结束运行" SKJAlarm.Adodc7.Recordset.Fields(2) = Now SKJAlarm.Adodc7.Recordset.Update End End Sub只贴出部份代码,其它代码与这个无关,请高手指点!
排序不就行了, order by 序列 desc
select 语句的最后加上order by 例如: Adodc7.RecordSource = "select * from 系统日志" 修改为: Adodc7.RecordSource = "select * from 系统日志 order by ID desc" 假设你的系统日志有ID列,就是按照ID从大到小排序,这样最后一行就显示在最上面了。
因为,标鉴处于最后一行中.所以,添加之间设置ADODC7.RECORDSET.MOVEFIRST
因为,标鉴处于最后一行中.所以,添加之前,设置ADODC7.RECORDSET.MOVEFIRST
用日期时间来排序就可以实现了最后一条记录始终显示在第一行,既然你是出现故障你肯定会有故障的时间字段,按照这个字段进行排序把“order by 时间 desc”放到你的sql语句最后就可以达到效果了,不过还要看你记录里面的日期时间字段的属性是否是日期型,如果不是就会出错
Adodc1.RecordSource = "select * from 报警记录 where 报警时间 > now Order By 报警时间 DESC"
谢谢各位高手指点已经解决该问题Adodc7.RecordSource = "select * from 系统日志 order by 运行时间 desc"
Public adors As New ADODB.RecordsetPrivate Sub AlarmTime_Click()
If AlarmTime.Value Then
DataStart.Enabled = True
DataEnd.Enabled = True
Else
DataStart.Enabled = False
DataEnd.Enabled = False
End If
End SubPrivate Sub DeviceArea_Click()
If DeviceArea.Value Then
DeviceAreaTxt.Enabled = True
Else
DeviceAreaTxt.Enabled = False
End If
End SubPrivate Sub DeviceName_Click()
If DeviceName.Value Then
DeviceNameTxt.Enabled = True
Else
DeviceNameTxt.Enabled = False
End If
End SubPrivate Sub Form_Load()
MainButton.Picture = MainUp.Picture
SendButton.Picture = SendUp.Picture
TransmissionButton.Picture = TransmissionUp.Picture
DryingButton.Picture = DryingUp.Picture
ReclaimButton.Picture = ReclaimUp.Picture
AlarmButton.Picture = AlarmUp.Picture
ExitButton.Picture = ExitUp.Picture
DataGrid1.Visible = True
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\SKJ.mdb " & ";Persist Security Info=False"
Adodc1.RecordSource = "select * from 报警记录 where 报警时间 > now"
Adodc1.Refresh
Frame2.Visible = False
End SubPrivate Sub TabStrip1_Click()
Select Case TabStrip1.SelectedItem.Index
Case 1
DataGrid1.Visible = True
DataGrid2.Visible = False
DataGrid3.Visible = False
DataGrid4.Visible = False
DataGrid5.Visible = False
DataGrid6.Visible = False
DataGrid7.Visible = False
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\SKJ.mdb " & ";Persist Security Info=False"
Adodc1.RecordSource = "select * from 报警记录 where 报警时间 > now"
Frame2.Visible = False
Case 4
DataGrid4.Visible = True
DataGrid1.Visible = False
DataGrid2.Visible = False
DataGrid3.Visible = False
DataGrid5.Visible = False
DataGrid6.Visible = False
DataGrid7.Visible = False
Adodc4.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\SKJ.mdb " & ";Persist Security Info=False"
Adodc4.RecordSource = "select * from 故障记录 where 故障时间 > now"
Adodc4.Refresh
Frame2.Visible = False
Case 7
DataGrid7.Visible = True
DataGrid1.Visible = False
DataGrid2.Visible = False
DataGrid3.Visible = False
DataGrid4.Visible = False
DataGrid5.Visible = False
DataGrid6.Visible = False
Adodc7.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\SKJ.mdb " & ";Persist Security Info=False"
Adodc7.RecordSource = "select * from 系统日志"
Adodc7.Refresh
Frame2.Visible = False
End Select
End Sub'退出系统按钮的退出动作
Private Sub ExitButton_Click()
SKJAlarm.Adodc7.Recordset.AddNew '将系统结束运行状态记录到系统日志
SKJAlarm.Adodc7.Recordset.Fields(0) = "系统停止"
SKJAlarm.Adodc7.Recordset.Fields(1) = "结束运行"
SKJAlarm.Adodc7.Recordset.Fields(2) = Now
SKJAlarm.Adodc7.Recordset.Update
End
End Sub只贴出部份代码,其它代码与这个无关,请高手指点!
例如:
Adodc7.RecordSource = "select * from 系统日志"
修改为:
Adodc7.RecordSource = "select * from 系统日志 order by ID desc"
假设你的系统日志有ID列,就是按照ID从大到小排序,这样最后一行就显示在最上面了。