Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

sp_setapprole encryption and .NET

694 views
Skip to first unread message

msnews.microsoft.com

unread,
Aug 14, 2004, 4:25:34 PM8/14/04
to
If I run
exec sp_setapprole @rolename='app',@password={Encrypt
N'app'},@encrypt='odbc'
from MS query analyzer it sets up okay. I have a guest account in the
public role in the database I connect to run this.

If I am my .Net program and try to run it as follows
strConn="Initial Catalog=MyDB;Data Source=MyServer;user id=guest";
SqlConnection oConn=new SqlConnection(strConn);
oConn.Open();
SqlCommand oCmd=new System.Data.SqlClient.SqlCommand("exec sp_setapprole
@rolename='app',@password={Encrypt N'app'},@encrypt='odbc'",oConn);
iResult=(int)oCmd.ExecuteNonQuery();

It throws an error
'Encrypt' is not a recognized ODBC date/time extension option.

If I take out the Encrypt part, as shown below, it works fine.
SqlCommand oCmd=new System.Data.SqlClient.SqlCommand("exec sp_setapprole
@rolename='app',@password='app',@encrypt='odbc'",oConn);

Any ideas on the error?

Erland Sommarskog

unread,
Aug 14, 2004, 6:23:58 PM8/14/04
to

It appears that SqlClient does not support this syntax. The only work-
around I can think of for the moment is to use the OleDb .Net provider
instead.

There are special newsgroups devoted to ADO .Net, I think you should
consult these as well for better advice.


--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp

0 new messages