请大家帮我解决啊
帮我看看下面的代码怎么改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#