?
Solved

SQL Server Application Role Activation from within Delphi

Posted on 2004-08-26
3
Medium Priority
?
287 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
[X]
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
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
bpana earned 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month11 days, 13 hours left to enroll

752 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