注册 登录
编程论坛 ASP.NET技术论坛

(三层结构)ASP.NET数据库连接问题?

liaohongchu 发布于 2010-03-11 11:10, 935 次点击
数据库连接问题?
ApplicationConfig.cs
namespace LIBRARYMSBLL
{
    public class ApplicationConfig
    {
        public static string ConnectionString()
        {
         
           return "Data Source=.;Initial Catalog=LibraryMS;User ID=sa;Password=123; Connection Reset=FALSE;max pool size=500;min pool size=5" providerName="System.Data.SqlClient";
        }
        public static string UpdateCache()
        {
           
           return "Data Source=.;Initial Catalog=LibraryMS;User ID=sa;Password=123; Connection Reset=FALSE;max pool size=500;min pool size=5" providerName="System.Data.SqlClient";
        }
    }
}

BookBLL.cs
public BookBLL()
        {
            connection = new SqlConnection();
            connection.ConnectionString = ApplicationConfig.ConnectionString();
            try
            {
                connection.Open();
                selfConn = true;
            }
            catch
            {
                connection.ConnectionString = ApplicationConfig.UpdateCache();
                connection.Open();
                selfConn = true;
            }
            finally
            {
                dal = new BookDAL(connection, transaction);
            }
        }

web.config
<add name="LibraryMSConnectionString" connectionString="Data Source=.;Initial Catalog=LibraryMS;User ID=sa;Password=123; Connection Reset=FALSE;max pool size=500;min pool size=5" providerName="System.Data.SqlClient" />
        <add name="LIBRARYMSConnectionString1" connectionString="Data Source=.;Initial Catalog=LibraryMS;User ID=sa;Password=123; Connection Reset=FALSE;max pool size=500;min pool size=5" providerName="System.Data.SqlClient" />
错误提示:
在建立与服务器的连接时出错。在连接到 SQL Server 2005 时,在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。 (provider: SQL 网络接口, error: 26 - 定位指定的服务器/实例时出错)

还有个问题
只有本站会员才能查看附件,请 登录

上面的BLL DAL Model web 在不通的目录 ,他们是如何联系起来的呢?

哪位高手能详细解答下吗? 谢谢
2 回复
#2
aspic2010-03-11 11:39
引用呗~
数据库连接问题好像跟三层不三层没什么关系吧
sql2005默认没有打开远程连接
#3
丫伊丫2010-03-11 16:02
打开Sqlserver2005——>配置工具——>服务和连接的外围应用配置器——>远程连接——>同时使用TCP/IP和named pipes
1