日期:2014-05-18  浏览次数:20410 次

vs2005+sql2005发布网站,数据库怎么连接
用VS2005做了个网站。在本地SQL SMS中附加数据库。发布到IIS中,显示“/photo”应用程序中的服务器错误。
--------------------------------------------

CREATE DATABASE permission denied in database 'master'.
An attempt to attach an auto-named database for file g:\inetpub\wwwroot\photo\App_Data\Personal.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. 


请问,网站发布时,对数据库应该注意点什么,该怎么发布数据库。

------解决方案--------------------
关注
------解决方案--------------------
要在web.cfg里面配置连接字符串才行的
------解决方案--------------------
代码里:
string conStr = System.Configuration.ConfigurationManager.AppSettings["ConnString"];
SqlConnection con = new SqlConnection(conStr);

Web.config里
<appSettings>
<add key="ConnString" value="server=.;database=MyCarNews;uid=sa;pwd="/>
</appSettings>