发表于:2003/12/10 10:55:00
#0楼
我现在用VB对ACESS数据库进行ADO操作,我在ACESS中建有一个警报信息表和实时警报表,当警报位触发后,VB在警报信息表中查询到信息,写入到实时警报表(DbGrid+DAOData控件显示)。当该位正常时,根据警报号在表中删除掉信息。但是我现在发现,虽然我在表删除,而且对DBGrid执行了Requery,但是DbGrid的信息还是没有删除。关掉程序后再运行就发现DbGrid的信息没有了。
还有为了执行对DBGrid中的数据进行操作,却不能使用FIND。
下面是两个ALARM过程,现在我已没什么办法,请思南先生及各位大侠给点经验和处理警报的思路。
Private Sub AlarmAdd(Number As Integer)
Dim mrc As ADODB.Recordset
txtsql = "select * from alarm where number='" & Trim(Number) & "'"
Set mrc = ExecuteSQL(txtsql)
If mrc.EOF = False Then
Exit Sub
Else
txtsql = "select chitext from alarmlist where number='" & Trim(Number) & "'"
Set mrc = ExecuteSQL(txtsql)
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields(0) = Trim(Number)
Adodc1.Recordset.Fields(1) = Now()
Adodc1.Recordset.Fields(2) = mrc.Fields(0)
Adodc1.Recordset.Update
End If
End Sub
Private Sub AlarmCanel(Number As Integer)
Dim str As String
If Number > 9998 Then
Exit Sub
ElseIf Adodc1.Recordset.EOF And Adodc1.Recordset.BOF Then
Exit Sub
Else
Dim mrc As ADODB.Recordset‘以下本可以用ADODB.Recordset.find number 来找出错的错误记录,但程序出错。
txtsql = "select * from alarm where number='" & Trim(Number) & "'"
Set mrc = ExecuteSQL(txtsql)
If mrc.EOF = False Then
mrc.Delete
mrc.Update
Adodc1.Recordset.Requery
Adodc1.Recordset.Update
End If
End If
End Sub
还有为了执行对DBGrid中的数据进行操作,却不能使用FIND。
下面是两个ALARM过程,现在我已没什么办法,请思南先生及各位大侠给点经验和处理警报的思路。
Private Sub AlarmAdd(Number As Integer)
Dim mrc As ADODB.Recordset
txtsql = "select * from alarm where number='" & Trim(Number) & "'"
Set mrc = ExecuteSQL(txtsql)
If mrc.EOF = False Then
Exit Sub
Else
txtsql = "select chitext from alarmlist where number='" & Trim(Number) & "'"
Set mrc = ExecuteSQL(txtsql)
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields(0) = Trim(Number)
Adodc1.Recordset.Fields(1) = Now()
Adodc1.Recordset.Fields(2) = mrc.Fields(0)
Adodc1.Recordset.Update
End If
End Sub
Private Sub AlarmCanel(Number As Integer)
Dim str As String
If Number > 9998 Then
Exit Sub
ElseIf Adodc1.Recordset.EOF And Adodc1.Recordset.BOF Then
Exit Sub
Else
Dim mrc As ADODB.Recordset‘以下本可以用ADODB.Recordset.find number 来找出错的错误记录,但程序出错。
txtsql = "select * from alarm where number='" & Trim(Number) & "'"
Set mrc = ExecuteSQL(txtsql)
If mrc.EOF = False Then
mrc.Delete
mrc.Update
Adodc1.Recordset.Requery
Adodc1.Recordset.Update
End If
End If
End Sub