The UserName property returns the Microsoft® SQL Server™ database user, determining privilege for the current connection.
object.UserName [= value]
| Part | Description | 
|---|---|
| object | Expression that evaluates to an object in the Applies To list | 
| value | String specifying an existing SQL Server database user by name | 
Members of the sysadmin fixed server role or db_owner fixed database role can set the UserName property to impersonate the database user specified. For more information, see SETUSER.
String
Read/write
HRESULT GetUserName(SQLDMO_LPBSTR pRetVal);
HRESULT SetUserName(SQLDMO_LPCSTR NewValue);
Note SQL-DMO strings are always returned as OLE BSTR objects. A C/C++ application obtains a reference to the string. The application must release the reference by using SysFreeString.