[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

SQL Server Application Role Activation from within Delphi

Posted on 2004-08-26
3
Medium Priority
?
289 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

649 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