我正在尝试使用sys.sysusers
连接到SQL Azure数据库,name
等于"myname@mydoman"
。问题是尝试使用连接字符串时
Data Source=tcp:coolsqldb.database.windows.net,1433;Initial Catalog=Cool;Persist Security Info=False;User [email protected];...
我得到了例外
Cannot open server "mydomain.com" requested by the login. The login failed.
at System.Data.SqlClient.SqlIn....
我试过在[email protected]
中使用引号,这样它就是ID='[email protected]'
,但没有运气。知道我能做什么吗?
如果在Azure Active Directory上创建这些标识,则可以将它们创建为Azure SQL数据库的用户。
CREATE USER [[email protected]] FROM EXTERNAL PROVIDER;
然后你的字符串连接必须改变,如下所示:
string ConnectionString =
@"Data Source=n9lxnyuzhv.database.windows.net; Authentication=Active Directory Password; Initial Catalog=testdb; [email protected]; PWD=MyPassWord!";
SqlConnection conn = new SqlConnection(ConnectionString);
conn.Open();
有关更多信息,请访问this以下文档。