Action must use an updatable query solution (from: http://jingyan.baidu.com/article/d5a880eb46345613f147cc16.html)

Source: Internet
Author: User

one sentence, in the Excel link statement, set IMEX = 1 (read-only) changed to IMEX = 0 (write only) or IMEX = 2 (read/write )! The following is an explanation:


Two days ago, we used oledb to connect to excel to extract the required data from multiple sheets in an Excel team,ProgramThe results are very simple and will soon come out. It takes a long time for the results to be selected manually. Now, the results are displayed in almost one click. The user is very satisfied. Because it is used by many people, the results are displayed on a page at the beginning. Later, they asked to write the results to another sheet in the xls file. I wrote a statement to immediately implement the rollback. I did not expect that "the operation must use an updatable query ". Because the reading result is normal, I started to think that the folder where the Excel file is located has no write permission. After the corresponding permissions are added, the results remain unchanged. There is no way to check the program. I checked the program carefully and found the problem. I used to read the Excel file and wrote the connection in the following format:

Private filename as string = server. mappath (". ") +" test.xls; extended properties = 'excel 8.0; HDR = yes; IMEX = 1' "dim constr as string =" provider = Microsoft. jet. oledb.4.0; Data Source ="
+ Filename pay special attention to extended properties = 'excel 8.0; HDR = yes; IMEX = 1' A: HDR (header row) if the specified value is yes, the first row of the worksheet in the Excel file is the column name. If the specified value is no, the first row of the worksheet in the Excel file is the item. No column name is B: the IMEX (Import Export mode) sets the Mex mode to have three modes, and the read/write behaviors are also different. After that, the 0 is export mode1 is import mode2 is linked.
Mode (full update capabilities)


Here, I particularly want to explain the IMEX parameter, because different modes represent different read/write behaviors: When IMEX = 0, the "Export mode" is used ", the Excel files opened in this mode can only be used for "writing" purposes. When IMEX = 1
For "Import mode", the Excel files opened in this mode can only be used for "read" purposes. When IMEX = 2, the connection mode is enabled. The Excel files enabled in this mode support both "read" and "write. After reading this, you don't have to say why I wrote it. I changed the connection to private filename as string = server. mappath (". ") +" test.xls; extended properties = 'excel 8.0; HDR = yes; IMEX = 2' "dim constr as string =" provider = Microsoft. jet. oledb.4.0; Data
Source = "+ filename run all OK.

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.