Solved

SQL Server Application Role Activation from within Delphi

Posted on 2004-08-26
3
278 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now