c# - How to allow SQL Server database connection from an ASP.NET web app and a Windows service? -
i have asp.net web application , windows service running on same server machine. both need connect same database, using following code:
using (sqlconnection cn = new sqlconnection(strdbconnect)) { cn.open(); //and on... }
but gives me exception when try connect service:
"cannot open user default database. login failed.\r\nlogin failed user 'nt authority\system'."
the connection string i'm using both is, may different on actual deployment server:
data source=.\sqlexpress;integrated security=sspi;attachdbfilename='c:\users\user\databases\app_data\database1.mdf';user instance=true;connection timeout=15
so i'm assuming need add sharing parameter connection string. question is, how ensure more 1 process can connect sql server database?
create specific user.
use user identity of app pool
use user identity service.
add user sql server necessary rights.
Comments
Post a Comment