Several attention issues using Visual Basic access to databases

zhaozj2021-02-17  59

Basic Problems of access to the database using several noting Visual: Zhang Rong Visual Basic 3.x For Windows is a Windows application to develop good language and use it to develop large-scale applications. It has the function of accessing various databases. Here will talk about several issues that use VB access to the database. First, how to access the database. VB Access Database provides two methods that use data control, which is the object to access the database. In both methods, all databases are related to the database: Connect, DatabaseName, Exclusive, Options, Readonly, Recordsoure. These attributes have a lot of books, and the author is no longer detailed. But sometimes you introduce the Connect, and DatabaseName, you often appear "Unable to find an installed ISAM" error when you set up RecordSou. The [ISAM] mentioned here is in the vb.ini file, which specifies the dynamic link library of the VB to the VB. The name of the database used in Connect must be in line with the name of the database in [ISAM], so you can easily open the database. Second, the bookmark pointer is the Bookmark property. When VB accesss the database, the records in the database are no record numbers. However, VB provides the Bookmark property to record the record pointer currently access record. This bookmark is equivalent to the record number. But the author discovered that the Bookmark property when using database control and using an object open database to access the same database is not universal. When you record the current record pointer of the database that is opened with the data control, then use the object to open this database, use the data-controlled Bookmark to find the positioning record, the Bookmark is not legal error. Third, pay attention to the difference between the HIDE method and the unload method. The HIDE method is hidden to the form you specify, but does not remove it from the memory, so the content of this form has not changed. The unload method is to delete the specified form (disappear from the screen and delete from memory). If you use lattice control in the current form to display record content, then hide this form with hide method, then you re-select the record to load lattice control, use the Show method to display hidden forms, at this time, the content in the lattice is still the old The content and new content did not replace the old content. Here, you need to use the unload method to delete the form, then the new record is loaded with the grid control. When you display the Show method, you can see new content. 4. Pay attention to the matching of variable types. When the database is accessed, the display record is generally used. Where grid.text is a substring type. However, some recorded data items are empty (NULL), that is, no data. If you put NULL in Grid.Text, it will obviously be wrong. So here you need to join the type of judgment, assign the NULL data item to the space skewers so that this problem can be resolved. 5. How to implement the net format print database record. The printer output object provided by VB has a form, a text box, a picture box, and a report. Here you can use report control to implement web format printouts. But report control requires report format files.prt. This file is designed by the report editor provided by VB to design the report format you need. The generated report file is all records of the output database, but often we only need some partial records in the database. How to implement some recorded net format printing? The method used by the author is to design a connection empty database file with the report editor, and then in the program run, in an empty database, then use the report control to print the output, so you can implement any you Report printouts required for data. 6. Pay attention to calling the DLL (Dynamic-Link Libraries, Dynamic Link Library) of the system.

转载请注明原文地址:https://www.9cbs.com/read-28965.html

New Post(0)