protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string MySqlConnection = "user id=sa;password=;Database =pubs;data source=127.0.0.1;Connect Timeout=30 ";
SqlConnection conn = new SqlConnection(MySqlConnection);
string sql = "select * from stores ";
SqlCommand comm = new SqlCommand(sql, conn);
conn.Open();
SqlDataReader dr = comm.ExecuteReader();
DataList1.DataSource=dr;
DataList1.DataBind();
conn.Close();
}
}
出错了 出错信息如下 :
在建立与服务器的连接时出错。在连接到 SQL Server 2005 时,在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。 (provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接)
------解决方案--------------------------------------------------------
http://lovewangshu.cnblogs.com/archive/2005/12/01/288815
------解决方案--------------------------------------------------------
string MySqlConnection = "Server=.;Database=pubs;uid=sa;pwd=; ";
------解决方案--------------------------------------------------------
UP
------解决方案--------------------------------------------------------
http://community.csdn.net/Expert/topic/4748/4748358.xml?temp=.1004602
------解决方案--------------------------------------------------------
连接串保存密码
------解决方案--------------------------------------------------------
http://www.cnblogs.com/soso/archive/2006/05/23/406937