sVirgo
asked on
Run SQLConfigDataSource from program as a standard user - Vista
I am running my application as standard user on Vista and SQLConfigDataSource to add system dsn fails.
How can I elevate this command or run as administrator.
int return = SQLConfigDataSource(hwndP, ODBC_ADD_SYS_DSN, "SQL Server",
"DSN=" + sTargetDSN + '\0' +
"Description=" + _T("") + '\0' +
"Server=" + sSQLServer + '\0' +
"Database=" + sSQLDatabase + '\0' +
"UID=sa"+'\0'+
"Trusted_Connection=No" + '\0' + '\0');
Thank you!
How can I elevate this command or run as administrator.
int return = SQLConfigDataSource(hwndP,
"DSN=" + sTargetDSN + '\0' +
"Description=" + _T("") + '\0' +
"Server=" + sSQLServer + '\0' +
"Database=" + sSQLDatabase + '\0' +
"UID=sa"+'\0'+
"Trusted_Connection=No" + '\0' + '\0');
Thank you!
ASKER
I already have this manifest file for my application(exe file). However, the code above is a part of dll file which is causing me problem. And it fails at this SQLConfigDataSource command. My exe file calls a function of the dll file to create system dsn.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have added manifest with exe file.
No, it does not ask me anything on this command, it just fails.
As a test, I tried to create system DSN manually by going to control panel as a standard user and it refuses and gives message can not create registry entries.
No, it does not ask me anything on this command, it just fails.
As a test, I tried to create system DSN manually by going to control panel as a standard user and it refuses and gives message can not create registry entries.
Is that the only mafest or are you isng two? If so, just try to merge the admin thing from the second one to your original manifest.
ASKER
This dll is used by other applications also. I am trying to fix piece by piece applications of the project for vista standard user.
I had sqlconnect command which did not work from this dll, so I had to connect with sql server authentication.
Now I am stuck with this command, is there no way to run this command run as admin. Like with Executeshell command or any other way.
I had sqlconnect command which did not work from this dll, so I had to connect with sql server authentication.
Now I am stuck with this command, is there no way to run this command run as admin. Like with Executeshell command or any other way.
ASKER
Any more clues to fix it?
This is starting to puzzle me. I wonder why it works in all other cases, just not here...
Oh, wrong button
ASKER
Hi jkr,
As an admin user on vista, offcourse it works.
But I am trying to create system DSN with standard user. I am not allowed unless I give admin password. I do not think that in real life the standard user would know the admin password.
So either I have to separate features which can be run by admin only and which can be run by standard user.
So there is no offend to your solution.
Thank you!
As an admin user on vista, offcourse it works.
But I am trying to create system DSN with standard user. I am not allowed unless I give admin password. I do not think that in real life the standard user would know the admin password.
So either I have to separate features which can be run by admin only and which can be run by standard user.
So there is no offend to your solution.
Thank you!
ASKER
Hi jkr,
May be I did not put question properly.
I was trying to create system DSN as a standard use without giving admin password.
Thank you!
May be I did not put question properly.
I was trying to create system DSN as a standard use without giving admin password.
Thank you!
Open in new window