VB Data Environments and Application Roles

You can use application roles in a Visual Basic (VB) Data Environment. To avoid resource-pooling problems, include the OLE DB Services = -2 option in the Connection object's ConnectionSource property. When you define the connection in the Data Environment UI, the dialog box has nowhere to enter the OLE DB Services option. However, you can add the extra text manually in the ConnectionSource property's connection string. The following example shows a completed ConnectionSource that uses Windows 2000/Windows NT authentication against a local server:

Provider=SQLOLEDB.1;Integrated Security=SSPI;OLE DB Services = -2;Persist
Security Info=False;Initial Catalog=Products;Data Source=(local

You can execute the sp_setapprole stored procedure in a Data Environment Connection object's ConnectionComplete event. This stored procedure activates the application role as soon as the connection is open, and the application role remains active as long as the connection endures. Figure A shows an example of how to use a Data Environment connection's ConnectComplete event procedure to execute the sp_setapprole stored procedure and activate the application role. After the stored procedure activates the application role, any Command and Recordset objects that the Connection object creates execute within the application role's security context.

Please or Register to post comments.

IT/Dev Connections

Las Vegas
September 30th - October 4th

Paul ThurottOur Experts will show you:
• Common SQL Server
Problems
• Best Practices for T-SQL
• SQL Server Integration
Services
• Database Development

Come See Mike Otey & Tim Ford in Person!

Early Registration Now Open

From the Blogs
May 9, 2013
blog

My ISO 8601-Compliant Signature 2

My family recently just "officially" announced that we're in the process of adopting a child from South Africa. We're quite excited, of course, but there's a ton of paperwork to do—along with the need for gobs of signatures....More
May 8, 2013
blog

Use SSIS for ETL from Hadoop

In this blog post, Mark Kromer walks you through using SSIS as a way to use ETL techniques using Microsoft's Hadoop on Windows (HDInsight) as a source using Hive connectors...More
Vision road sign
May 6, 2013
blog

Cheaters Never Win, Even in TPC Benchmarks

In this portion of the series on database benchmarking, I want to tell you about one of my favorite aspects of the TPC benchmarks – CHEATING....More
SQL Server Pro Forums

Get answers to questions, share tips, and engage with the SQL Server community in our Forums.