vb串口接收命令后怎么记录时间!
1.将收到数据时时间记录到数据库中
2.sql数据库 acess数据库 记录方法一样吗?
3.能不能给个例子
谢了!
[解决办法]
Private Sub Form_Load() Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\" & _ "Administrator\My Documents\11.mdb;Persist Security Info=False" Adodc1.CursorLocation = adUseClient Adodc1.CommandType = adCmdText Adodc1.RecordSource = "select * from itb1" Adodc1.Refresh Set DataGrid1.DataSource = Adodc1 iniMscommEnd SubPrivate Sub iniMscomm() On Error Resume Next'=====-----初始化通信串口-----===== MSComm1.CommPort = 1 MSComm1.Settings = "9600,N,8,1" MSComm1.PortOpen = True MSComm1.RThreshold = 1 MSComm1.InputLen = 0 MSComm1.InputMode = comInputModeBinary MSComm1.RTSEnable = True MSComm1.InBufferCount = 0End SubPrivate Sub MSComm1_OnComm()'=====>等待下位机触发各种事件<========== Dim t1 As Long t1 = Timer Select Case MSComm1.CommEvent Case comEvReceive '收到 RThreshold定义的字符数1字节 MSComm1.RThreshold = 0 Do DoEvents Loop While Timer - t1 < 1 Call Receive '调用接收过程处理数据 MSComm1.RThreshold = 1 End Select End SubPrivate Sub Receive() sql = "INSERT INTO itb1(a) VALUES (#" & Now & "#)" Adodc1.Recordset.ActiveConnection.Execute sql Adodc1.Refresh End Sub