Home > Software engineering >  Access multi-table query after modify the data
Access multi-table query after modify the data

Time:11-02

I now set up a database, in the library have more than one table of the same configuration, an unknown number, now I want to date a query in the database records, how to do this?
For example, I now have 2012201 3 two tables, table at the same field (serial number, test date, product number, test results, the analyst, note), I want to test date to retrieve the records in the two tables, and to show the Datagrid (serial number to change, starting from 1) again, can modify the remark,
My program:
Mysql="select * from (select * from 2012 union all select * from 2013) tem where testing date between #" & amp; The Format (myDTPicker_qi, "yyyy/mm/dd") & amp; "# and #" & amp; The Format (myDTPicker_zhi + 1, "yyyy/mm/dd) & amp; "#", "

Myrs. ActiveConnection=mycn
Myrs. Open mysql, mycn adOpenStatic, adLockPessimistic
Myzsl=myrs. RecordCount

'changes show the serial number of' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
Dim myrs_row As Integer

If myzsl & lt;> 0 Then
Myrs. MoveFirst
For myrs_row=0 To myzsl - 1
Myrs. Fields (0)=myrs_row + 1
Myrs. MoveNext
Next myrs_row
End the If
The Set my_DataGrid1. The DataSource connection database
=myrs'
What has happened is that if there is no change according to the serial number, the datagrid can be displayed, but with modified according to the serial number, will be an error, a multi-step operation errors, can you tell me how to achieve this function

CodePudding user response:

Look at this example:
 Private Sub Form_Load () 

ObjRecordset. ActiveConnection=objConnection
'the ADO connection object
ObjRecordset. CursorLocation=adUseClient
'you must use the client - side cursors
ObjRecordset. CursorType=adOpenStatic
'the client - sided server cursor must use this type
ObjRecordset. LockType=adLockBatchOptimistic

'the Northwind database
ObjRecordset. Open the "SELECT * FROM Customers JOIN the Orders ON" & amp; _
"Customers. CustomerID=Orders. CustomerID WHERE city=" & amp; _
"' London 'ORDER BY CustomerID"

ObjRecordset. The Properties (" Unique Table "). The Value="https://bbs.csdn.net/topics/Orders"
ObjRecordset. The Properties (" Resync Command "). The Value="https://bbs.csdn.net/topics/SELECT * FROM" & amp; _
"(SELECT * FROM Customers JOIN the Orders ON Customers. The CustomerID=" & amp; _
"The Orders. CustomerID WHERE city='London' ORDER BY CustomerID)" & amp; _
"WHERE the Orders. OrderID=?"

ObjRecordset. ActiveConnection=Nothing
'disconnected ADO you

The Set grdTest. The Datasource=objRecordset
End Sub

Private Sub Save ()
ObjRecordset. ActiveConnection=objConnection
'just for this purpose to reconnect

ObjRecordset. UpdateBatch
'don't forget to check for errors ADO collection

ObjRecordset. ActiveConnection=Nothing
'and then disconnect
End Sub
  • Related