I use login control in asp.net. this control creating a aspnetdb.mdf file in app_data folder and there is not any code in web config for connection to this db. in local web is working as correct but when web on IIs can not to conection to the aspnetdb. how to manage connection to aspnetdb by web config? I use follow cod in my web.config but when aspnetdb attach to sqlserver the web not working :
<add name="ApplicationServices"
connectionString="data source=.\SQLMIRZA;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|ASPNETDB.MDF;User Instance=true"
providerName="System.Data.SqlClient" />
One observation is that you are giving the full path of the
mdffile in the connection string.|DataDirectory|directory automatically points to theApp_Datefolder. so no need to give the full physical path of themdffile. this should also work -to connect to
mdffile directly you needSQLEXPRESSinstalled on your machine. check if your web server hasSQLEXPRESSinstance installed.if you instead attach the file to
MSSQLSERVERinstance. then your connection string should be changed to something like this -if this connection string doesn't work on your local machine then you can keep both in your
web.configand comment out one. something like this -here I have commented out the real/web connection string, so it will work on local machine. before deploying just just reverse the comments and it will work on web.