Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

SQL Server Application Role Activation from within Delphi

Posted on 2004-08-26
3
284 Views
Last Modified: 2010-04-05
Hi all,

PLEASE HELP!

I am currently developing an app that connects to a SQL Server 2000 database. I would very much like to make use of the SQL Server Application Role functionality, but I cannot seem to get it working. I have tried using a ADOStoredProc, ADOQuery, ADOCommand and even the ADOConnection directly to execute the stored procedure to activate using the Application Role.

What I could understand from all the documentation is that I must switch the current open connection from the user login password (in my case using Windows Authentication) by using a stored procedure called master.dbo.sp_SetAppRole with parameters @rolename and @password.

I have successfully tested this in SQL Query Analyzer, but cannot get this working from within Delphi.

Regards,
Johan Swart
0
Comment
Question by:johan777
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
bpana earned 500 total points
ID: 11906822
hi,

I made a test and it is working as expected.

Drop a TADOConnection on the form. Set it's ConnectionString property the the database containing the role.
On the Form's create method:
procedure TForm1.FormCreate(Sender: TObject);
begin
  ADOConnection1.Execute('EXEC sp_setapprole ''Role_Inventory'', ''role''');
end;

drop a TADOTable on the form. Set it's connection to the ADOConnection1. Leave the Active property set to False

procedure TForm1.Button1Click(Sender: TObject);
begin
  ADOTable1.TableName := 'Inventory';
  ADOTable1.Open;
end;

Bogdan
0
 
LVL 6

Expert Comment

by:bpana
ID: 11906930
btw, i'm using SQL Authentication.
0
 

Author Comment

by:johan777
ID: 11908839
Hi Bogdan,

Thanx very much!!! It works.

I appreciate the help!

Regards,
Johan Swart
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
delphi exception 7 68
Delphi selector screen 2 84
Making delphi communicate with a c# service 16 111
Twebbrowser in Fire monkey android scrolling to bottom 1 44
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question