当前位置:编程学习 > C#/ASP.NET >>

请大家帮我解决啊

帮我看看下面的代码怎么改
 private readonly string SQLCONNECTIONSTRING = ConfigurationSettings.AppSettings["SQLCONNECTIONSTRING"].ToString();
        private void Page_Load(object sender,System.EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindData();
            }
        }
        private void BindData()
        {
            string cmdText = "SELECT Top 12 * FROM goodsmessage ORDER BY itemid";
            SqlConnection myConnection = new SqlConnection(SQLCONNECTIONSTRING);
            SqlCommand myCommand = new SqlCommand(cmdText,myConnection);
            myConnection.Open();
            SqlDataReader dr = myCommand.ExecuteReader();
            BaseDataList.datasource = dr;
            BaseDataList.DataBind();
            dr.Close();
            myConnection.Close();
        }



在web.coning中还有
<add name="mydataConnectionString" connectionString="data source=localhost//PING\SQLEXPRESS;Initial Catalog=mydata;Integrated Security=True;Pooling=true" providerName="System.Data.SqlClient"/> --------------------编程问答-------------------- SqlCommand myCommand = new SqlCommand(cmdText,myConnection); 
            myConnection.Open(); 
这两句掉一下顺序看看
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,