Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Windows 7 - MySQL ODBC System DSN creation

23 Sep 2012   #1
Lea Massiot

Windows 7 Professional SP1 64bit
 
 
Windows 7 - MySQL ODBC System DSN creation

Hello and thank you for reading my post.

My software creates MySQL ODBC System DSNs...
... except it doesn't work with Windows 7.
It used to work with the previous Windows OSes including XP, Vista.
I've been struggling the whole day trying to find a solution.

*** I believe UAC (User Account Control) has something to do with this.
But I can't disable it as my customers have it usually enabled.
How can my application be allowed to create MySQL ODBC System DSNs and as a "normal" user?

*** The MySQL ODBC connector I have installed is:
mysql-connector-odbc-3.51.30-win32
and I have installed it logged as "Administrator".
(I also installed my application logged as "Administrator").

*** The MySQL server is on localhost for now... (that is to say on the same host as the application).

*** I've already updated the "Target" in the "Shortcut" tab in "Data Sources (ODBC) Properties" to "%windir%\syswow64\odbcad32.exe"
so that the "Drivers" tab is properly populated, including "MySQL ODBC 3.51 Driver".

*** Logged as "Administrator" (which shouldn't be of course: this account is disabled by default, I enabled it for testing reasons), MySQL ODBC DSNs are created but they are empty:
- only the "Data Source Name" field is not;
- the "TCP/IP Server", "User", "Password" and "Database" fields are empty.

*** In my application it results in the message: "No database selected".

*** If I'm logged as a "normal" user, MySQL ODBC System DSNs are not created at all
(or maybe they are but they do not appear in the "System DSN" tab).

I read something like: the application should be "elevated" but I don't know if it would solve the problem nor how to do it. Apparently UAC prevents applications from creating ODBC System DSNs... ! There has to be a way around!
Actually a solution is proposed on this website: http://kb.avecto.com/articles/how-to...dsn%E2%80%99s/
but I do not wish to buy this product especially if there exists a solution without it.

I really don't know what to do now...
can you help me?

Thank you and best regards.


My System SpecsSystem Spec
.
23 Sep 2012   #2
Alejandro85

Windows 7 Ultimate x64
 
 

Most likely yes, UAC is the cause of the problem. Changing system DSNs naturally requires administrator privileges and therefore CANNOT be done by normal users, UAC or not (UAC makes this worse by converting admins to normal users under the covers). But it's the normal, expected behavior, as regular applications aren't supposed to messing with global DSNs, and only elevated ones are allowed. Respecting that is the whole point of the admin/regular user distinction. You app seems to be abusing its administrative rights on pre-UAC systems.

First, as a side note, I think using DSNs is a bad programming practice, as it ties the database access to something not entirely manageable by the app itself. I would store the server/database/user/password somewhere else, where you know, and build a connection string from it at runtime and use that to connect, therefore forgetting the problems of DSNs. Such refactoring may be easy or complicated, depending how is the program made, but in the long run I think it's the best solution.

If you want to continue use DSNs, then at some point you must elevate the app to allow such change. I guess that the DSN is changed from a configuration screen somewhere where the user chooses the database, then the whole program simply uses that.
The idea is to create a second executable program and manifest it as "require administrator" and make that program make the changes, after UAC prompt. The main one can call that second passing the data to be used in the DSN.
While it looks complicated, it's the normal way an application elevates for certain operations only in Win Vista+, without executing the whole program as administrator everytime.
My System SpecsSystem Spec
24 Sep 2012   #3
Lea Massiot

Windows 7 Professional SP1 64bit
 
 

Actually, the problem is not UAC.
I re-installed a MySQL server and a MyODBC driver which are "compatible" with each other.
Even with UAC enabled, I can now use my application normally with successful accesses to the databases through the MyODBC connector.

This is an interesting article:
"The 32-bit version of the ODBC Administrator tool and the 64-bit version of the ODBC Administrator tool display both the 32-bit user DSNs and the 64-bit user DSNs in a 64-bit version of the Windows operating system":
http://support.microsoft.com/kb/942976

Best regards.
My System SpecsSystem Spec
.

Reply

 Windows 7 - MySQL ODBC System DSN creation




Thread Tools




Similar help and support threads
Thread Forum
Disable Automatic System Restore Point Creation?
Is it possible to disable automatic System Restore Point creation (to prevent Windows to create restore points daily and after (re)installing programs / Windows updates)? I want to manually create System Restore Points because automatic creation uses too much space, because I install new...
Backup and Restore
System image/repair disc creation and use questions
Hello, * Before I begin I will add that I am aware of the excellent tutorials available here and will be using them =) * I need to migrate to a hard drive that already has windows 7 HP 64bit on it. I do not however want the registry information and all of the drivers and bloat-ware that...
Backup and Restore
System Reset, Not BSOD, When Using Skyrim Creation Kit
For the past few days my Win7 computer would reset to BIOS. No warnings, just BAM! hard reboot of the computer. I've unchecked the box under computer/properties that would Automatically Restart the system on crash. So that's just one thing I've tried in order to try to find the issue. I think...
General Discussion
Backup and system image creation do not work
It seems a bit ridiculous to write about the subject. (soon I can say year after year) Microsoft is very well aware of this - and other related problems. Yet - no correction. Be it MS or Nokia, I give them all they deserve, here we go: I had this problem (error code 0x8078012D) with backup and...
Backup and Restore
Win7 System repair disc creation error
I'm trying to 'Create a system repair disc' but keep getting this error message: System repair disc could not be created. The request is not supported (0x80070032). This is trying to use my CDRW. If I try to use my DVDRW the error message I get is same but with a Unspecified error (0x8004005). ...
Performance & Maintenance
System Image creation question
Hi all. Running a nice shiny new copy of win 7 home premium and have set about backing up the install. The system has two disks, both sata, a 230 GB basic disk for the OS and boot partitions and a 1TB dynamic for my data. When i try to create a system image of the system drive (C:) to a...
Backup and Restore


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 10:28.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App