沒有VBA的動態數據連接字符串

[英]Dynamic data connection string without VBA


Is it possible to have a connection string depend on a cell value or a named formula in an .xlsx file (i.e. non-macro enabled sheet)?

連接字符串是否可能依賴於.xlsx文件中的單元格值或命名公式(即非宏啟用的表)?


Background:

背景:

Every month I create a new workbook and update the external data source. This way I have workbooks with the results for each month and can always go back to look at a past month's data.

每個月我都會創建一個新的工作簿並更新外部數據源。這樣我就有了每個月的結果的工作簿,並且總是可以回顧過去一個月的數據。

Now, since I use multiple pivot tables on the same data, I use a data connection. The connection string looks something like this, of which the data source is the relevant one.

現在,由於我在相同的數據上使用多個數據透視表,所以我使用數據連接。連接字符串看起來是這樣的,其中數據源是相關的數據源。

Provider=Microsoft.ACE.OLEDB.12.0;
User ID=Admin;
Data Source=C:\pathtofile\myworkbook1705.xlsx;
Mode=Share Deny Write;
Extended Properties="HDR=NO;
";
Jet OLEDB // etc. etc //

I usually update the data source path manually, but since I want to expand the project I am doing to multiple other tasks, this manual update procedure becomes tiresome (change 1705 in the file path to 1706 from a cell value).

我通常手動更新數據源路徑,但是由於我想擴展我正在執行的項目到多個其他任務,這個手動更新過程變得很煩人(將文件路徑中的1705從單元格值更改為1706)。

A few reasons keep me from making the solution in VBA:

有幾個原因讓我無法在VBA中找到解決方案:

  • Security warning from macro-enabled file.
  • 來自啟用宏的文件的安全警告。
  • Users know Excel-sheets as .xlsx and may not recognize .xlm.
  • 用戶知道Excel-sheets是.xlsx,但可能不認識.xlm。
  • Inheritance. My successor, who eventually needs to edit something in the sheet might not know VBA.
  • 繼承。我的繼任者,最終需要在工作表中編輯一些東西,可能不知道VBA。

I have searched around with no success. Relevant links that unfortunately do not answer the question are linked below.

我到處找也沒找到。遺憾的是,相關鏈接沒有回答這個問題。

1 个解决方案

#1


1  

Long story short - NO. It is a giant security issue this way. If you find a way to do it, inform Microsoft immediately, they would be happy to fix it :) .

長話短說-不。這是一個巨大的安全問題。如果你找到了解決的辦法,立即通知微軟,他們會很樂意解決的:)。

It would be definitely considered a bad practice by anyone who has ever earned a single dollar with SQL to read the data from a cell in Excel. I mean, the connection string is probably the most sensitive information that you possess. Even if you use VBA, make sure that the passwords are always written by the user in the cells (or through a form) and then erased. Not hardcoded in the code.

任何一個用SQL賺過一美元的人,在Excel中讀取計算單元的數據肯定會被認為是一種糟糕的做法。我的意思是,連接字符串可能是您擁有的最敏感的信息。即使您使用VBA,也要確保密碼始終由用戶在單元格(或通過表單)中編寫,然后刪除。代碼中沒有硬編碼。

Microsoft can be considered bad by plenty of people, but they would never leave such a security hole in their products.

很多人都認為微軟不好,但他們絕不會在自己的產品上留下這樣的安全漏洞。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2017/06/29/729e88a04a3e56521e229280f848dcc8.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com