Home > Software engineering >  Vb database data problems
Vb database data problems

Time:10-31

Purpose is simple: is to a serial port from the data in the database, but wrote a program show that the real-time error 91 object variable or variables with block is not set, please temporarily suspended
Private Sub MSComm1_OnComm ()
Select Case mEvent MSComm1.Com


Case comEvReceive 'received RThreshold # of
Dim hk As the Variant
'Dim conn As New adodb. Connection
Xv: hk=MSComm1. Input
If Check2. Value=https://bbs.csdn.net/topics/1 Then
Text1. Text=Text1. Text & amp; Hex (hk (0)) & amp; "
"
The Else
Text1. Text=Text1. Text & amp; Hk
Adodc1. You. AddNew
Adodc1. You. Fields (" data ")=Text1. Text

End the If

If MSComm1. InBufferCount & lt;> 0 Then
GoTo xv
End the If
End the Select
End Sub

CodePudding user response:

Adodc1 into the controls in the window, have set up a database related parameters?

CodePudding user response:

Adodc1 controls with no database connection is established

CodePudding user response:

http://download.csdn.net/detail/veron_04/3827200

CodePudding user response:

 '┏ 〓 〓 〓 〓 〓 〓 〓 〓 〓 GetRsFromMdb, start 〓 〓 〓 〓 〓 〓 〓 〓 〓 ┓ 
'[abstract] :
'read ACCESS MDB format file specified in the table data
The Function GetRsFromMdb (MdbFile As String, Table, Optional Where As String, Optional Pass As String, Optional ErrInfo As String, Optional User As String) As the ADODB library you
'[44] mycode_id: edittime: 2012/4/13 8:14:13
On Error GoTo Err
ErrInfo=""
Dim conn As ADODB. Connection
Dim As Sql String
Set the conn=CreateObject (" adodb. Connection ")
Conn. Open "DBQ=" + MdbFile + "; Defaultdir=; Driver={Microsoft access driver (*. MDB)};" , the User, Pass
The Set GetRsFromMdb=CreateObject (" adodb. You ")
Sql="select * from []" & amp; Table & amp; "" & amp; Where
GetRsFromMdb. The Open Sql, conn, 1, 3
The Exit Function
Err:
DebugErr "GetRsFromAccdb
"ErrInfo="wrong number:" & amp; Err. Number & amp; VbCrLf & amp; "Error message:" & amp; Err. The Description
End the Function
'┗ 〓 〓 〓 〓 〓 〓 〓 〓 〓 GetRsFromMdb, end 〓 〓 〓 〓 〓 〓 〓 〓 〓 ┛
DIM the rS AS the ADODB library you
SET the RS=GetRsFromMdb (" C: \ 1. MDB ", "table 1")
RS. ADDNEW
1 RS (" fields ")="33", "
RS. UPDATE
RS. CLOSE
  •  Tags:  
  • VBA
  • Related