asp.net2005连接数据库字符串

1、        public static SqlConnection GetConn()
        {
            SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=Test;Integrated Security=True");
            return conn;
        }
2、web.config
 <connectionStrings>
  <!--
     本地测试连接字符串
    <add name="SQLConnectionStirng" connectionString="server=.;database=h164666;uid=sa;pwd=800823;"/>
    外网测试链接字符串
    <add name="SQLConnectionStirng" connectionString="Server=db720.now.net.cn;DataBase=dbh164666;Uid=h164666;Pwd=mtawnz;"/>
     -->
  <add name="SQLConnectionStirng" connectionString="server=.;database=test;uid=sa;pwd=sa;"/>
 </connectionStrings>

你可能感兴趣的:(asp.net)