我的web.config里的代码是这样的
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
<add key ="dsn" value="Data Source=localhost;UID=sa;PWD=sa;DATABASE=SMS">
</add>
</appSettings>
<system.web>
<compilation debug="true"/></system.web></configuration>
起始页的代码是这样的
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
string strconn=ConfigurationSettings.AppSettings["dsn"];
TextBox1.Text = strconn;
//SqlConnection cn = new SqlConnection(strconn);
//cn.Open();
//string strsql = "select * from users where user_id='" + TextBox1.Text + "'and user_password='" + TextBox2.Text + "'";
//SqlCommand cm = new SqlCommand(strsql, cn);
//SqlDataReader dr = cm.ExecuteReader();
//if (dr.Read())
//{
// Session["user_id"] = dr["user_id"];
// Session["user_power"] = dr["user_power"];
// if ((int)Session["user_power"] == 0)
// {
// Response.Redirect("infor.aspx");
// }
// else
// {
// Response.Redirect("student.aspx");
// }
//}
//else
//{
// TextBox3.Text = "对不起,登录失败!";
//}
//cn.Close();
}
}
但是运行时却出现这样的错误信息,
C:\Documents and Settings\dinjin\My Documents\Visual Studio 2005\WebSites\WebSite1\Default.aspx.cs(18,24): 警告 CS0618: “System.Configuration.ConfigurationSettings.AppSettings”已过时:“This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings”
C:\Documents and Settings\dinjin\My Documents\Visual Studio 2005\WebSites\WebSite1\Default.aspx(29,65): 错误 CS0117: “ASP.default_aspx”并不包含“TextBox3_TextChanged”的定义
请大家帮我看看是怎么回事,我用的是2005的