Access database structure Update (Part 1)

Source: Internet
Author: User

Recently I am working on a small project, where the ACCESS database is used. to support automatic updates, you have encountered the problem of how to update the ACCESS database online. my idea is: Download the database update script to the local through online upgrade, and then run the update script when the program starts to achieve online database update. determined that this method is theoretically feasible, and began to design.

First, download the script file from the server to the local machine. it is easy to implement the upgrader control provided by netizens through improvement. however, a problem occurred while running the script. because the ACCESS database is different from the SQL database after all, there is no way to write the stored procedure, there is no sysobject table for reference, and even the if statement is different. I started to write a script to add the table structure:

If not exists (select * From DBO. sysobjects where id = object_id ('bandregion') and objectproperty (ID, N 'isusertable') = 1)
Create Table bandarea (
Areaid int identity (1, 1) primary key,
Carid varchar (20 ),
City varchar (50)
)
Go

The script cannot be run. expect "insert, update, delete", etc. only by searching for information on the internet can we find that the ACCESS database does not have a sysobjects table, and the IF syntax is incorrect. in fact, access also has a system table called msysobjects. in addition, you still need to take a one-to-one twists and turns to find your true face. in the access library, set options-> View to hide the object. Only after the system object is checked is visible. to read and write this table, you also need to modify the read and write permissions of this table in Security> user and group permissions. you can read and write this table through one flip. however, the IF syntax is still incorrect. with help from netizens, we know that the usage is in the form of select IIF (a-B =, 0) from table. I still cannot use the above script to update it. later I thought of using the version number to control it. each version corresponds to a series of SQL scripts, which are determined by the database version. in this way, I can avoid using the if statement and directly run the create script.

The data structure update problem has been solved, and the initial values in the table have to be updated. How can this problem be implemented? Next I will describe this process.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.