Home > Software engineering >  Vb6 operation access some of the problems
Vb6 operation access some of the problems

Time:10-01

If the same access database files, corresponding to two adodc and datagrid, a scan, a query, if in the form1, showed normal;
If the query in form2, it shows that the first record of the first field value is gone, the remainder is normal, but the original scan the database of the value of this field still exists,
I don't know why? Please expert advice, code for: Form2. Adodc2. Refresh

CodePudding user response:

Don't use Adodc access data, with direct access to the Adodb library database, data set (you), then bound to the controls, according to

Reference path: http://bbs.csdn.net/topics/390968964

CodePudding user response:

After download Windows. The adodb library DLL, run regsvr32 adodb. DLL, prompt loaded. The adodb library DLL, but didn't find DLLRegisterServer entry points, unable to register this file, cannot use the adodb tools,

CodePudding user response:

2.5 quote Microsoft in VB6 ActiveX Data Object

CodePudding user response:

Download the latest MDAC installed once, not all of the components to register a DLL can use only,

CodePudding user response:

Don't use controls, directly using ADO

CodePudding user response:

After the adodb library have a little bit more simple, and the database connection, and the datagrid bound can be achieved, according to add, delete, change,
Private Sub Form_Load ()
Dim cn As New ADODB. Connection
Dim the rs As New ADODB. You
Dim connect_string As String
Set the cn=New ADODB. Connection
Set the rs=New ADODB. You
Connect_string="PROVIDER=Microsoft. Jet. The OLEDB. 4.0. Data Source="& amp; App. The Path & amp; "\ electrical library. MDB. Persist Security Info=False "
Rs. The open connect_string
End Sub
Run after prompt real-time error 3709: can't run the operation, in this context may have been closed or invalid,
Advice on how to change, thank you.

CodePudding user response:

Can be displayed, but can't change, don't know where is wrong,
Private Sub Form_Load ()
Dim cn As New ADODB. Connection
Dim the rs As New ADODB. You

Set the cn=New ADODB. Connection
Set the rs=New ADODB. You
Cn. CursorLocation=adUseClient
Cn. The ConnectionString="PROVIDER=Microsoft. Jet. The OLEDB. 4.0; Data Source="& amp; App. The Path & amp; "\ electrical library. MDB. Persist Security Info=False "
Cn. Open
Rs. The open (" select * from the electrical "), cn, adOpenDynamic, adLockBatchOptimistic
The Set DataGrid1.
the DataSource=rsDataGrid1. AllowAddNew=True
DataGrid1. AllowDelete=True
DataGrid1. AllowUpdate=True
DataGrid1. Refresh

End Sub

CodePudding user response:

First of all, the whole project to share the same Connection instance, otherwise it is multiple sessions, one session locking the record another session can't edit is very normal ah,
Second, that you browse in read-only mode,

CodePudding user response:

This is a Bug, when your DataGrid control as you focus, will appear this problem, you are in the properties window of DataGrid1, the TabIndex instead of the value other than zero, of course, the premise is there's other controls on the form,

CodePudding user response:

Oh, this is the problem, thanks a lot,

CodePudding user response:

Still can't avoid the user to click on the DataGrid give its focus, and then switch to the on Form2 execute queries,

Actually interface design also has a problem, the editor state (open Form1), should not be queried at the same time (to open the Form2),
DataGrid editing is actually the whole table as a unit of data, the data unit before didn't finish editing, cannot be used,

CodePudding user response:

The focus is solved
Other controls TabIndex instead of the values other than 0, the tabstop property to true, visible to true,
There are still problems
adodbAdodc cannot be completely shut down, exit button is not available, must click X to close the window, and seems to be not too good, do not modify the content of the adodb library,
The whole project to share the same Connection instance, only the adodb library form1 an application of the load,
Cn. CursorLocation=adUseClient
Or rs. CursorLocation=adUseClient

CodePudding user response:

1 cn. CursorLocation=adUseClient, rs object inherit the property of the Connection object

2 try
ADODC1. You. ActiveConnection. Close

In addition, agree with tiger, having used the ADODB Connection and RecordsSet object, can need not ADODC doesn't have to, which is united,
You can leverage existing in Form2 cn opens a new rs2, then

The Set DataGrid2. The DataSource=rs2

3 do not modify, you said may be related to you to set adLockBatchOptimistic, try

Rs. UpdateBatch

CodePudding user response:

1, the use of rs. CursorLocation=adUseClient or cn. CursorLocation=adUseClient effect is the same,
2, ADODC1. You. ActiveConnection. Close and ADODC1. You. As the Close out process,
Such as add Form1. Hide, can Hide interface, equivalent to quit,
3, adLockBatchOptimistic change into adLockOptimistic, can modify, rs. Update need not be changed,
4, adodb, run the program, click exit, prompt "current line unavailable,"
Private Sub exit_Click ()
Rs. Close
Set the rs=Nothing
Form1. Hide
Form2. Hide
End Sub

CodePudding user response:

Private Sub exit_Click ()
Rs. Close
Set the rs=Nothing
Form1. Hide
Form2. Hide
End Sub
Run without problem, but can't refund process,
Private Sub exit_Click ()
Set the rs=Nothing
Unload Form2
Unload Form1
End Sub
Run after errors, or out of the process,
  • Related