System.NullReferenceException: 未将对象引用设置到对象的实例。
using System;using System.Data;
using System.Configuration;
using System.Collections;
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 adminmofiy : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string str = ConfigurationSettings.AppSettings["dsn"];
SqlConnection cn = new SqlConnection(str);
cn.Open();
int straid = Convert.ToInt32(Request.QueryString["aid"].ToString());
string mysql = "SELECT * FROM admin WHERE (aid =" + straid + ")";
// SELECT * FROM Goods WHERE (GID = '10001')
SqlCommand cm = new SqlCommand(mysql, cn);
// = CommandType.StoredProcedure;
//cm.Parameters.Add("@GID", SqlDbType.Int);
//cm.Parameters["@GID"].Value = Convert.ToInt32(Request.QueryString["gid"].ToString());
SqlDataReader dr = cm.ExecuteReader();
if (dr.Read())
{
lbl_aid.Text = dr["aid"].ToString();
T_aname.Text = dr["aname"].ToString();
T_apassword.Text = dr["apassword"].ToString();
T_apower.Text = dr["apower"].ToString();
T_adep.Text = dr["adep"].ToString();
}
else
{
Response.Write("对不起,没有该人员信息");
Response.End();
}
}
int straid = Convert.ToInt32(Request.QueryString["aid"].ToString());这一行报错