问题描述
我已经制作了GUI,可以按
形成对数据库的常规操作(加载现有数据,修改或添加新条目)。 GUI使用原始 WinAPI在
C ++
中制作。
问题出在连接字符串中。它是硬编码的,因此它强制用户将数据库保存在GUI所在的同一文件夹中。
以下是 C ++
中的示例,使用 ADO
:
static wchar_t * bstrConnect = L Provider = Microsoft.ACE.OLEDB.12.0; \
Data Source = .\\MyDatabase.accdb;
我希望在数据库所在的位置允许用户自由选择,但我不知道如何将应用程序/连接字符串修改为这样做。
我试图在这里搜索一些例子,并在网上搜索但没有成功。也许我是初学者并且自学成才与此有关。
问题:
是否有一个示例/教程/文档可以向我展示处理这种场景的正确原则?
I have made GUI that can perform usual operations with the database ( load existing data, modify it or add new entries). GUI is made in
C++
using raw WinAPI.
The problem is in connection string. It is hardcoded so it forces the user to keep the database in the same folder where the GUI is.
Below is the example in C++
, using ADO
:
static wchar_t *bstrConnect= L"Provider=Microsoft.ACE.OLEDB.12.0;\ Data Source = .\\MyDatabase.accdb";
I wish to allow user to have freedom of choice when it comes to where database will be located but I do not know how to modify the application/connection string to do this.
I have tried to search here for examples, and have searched online but had no success. Perhaps me being a beginner and self-taught has something to do with that.
QUESTION:
Is there an example/tutorial/documentation that can show me the correct principle for handling this type of "scenario"?
这篇关于消除连接字符串的硬编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!