public partial class WebForm3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            WebForm2 fg = new WebForm2();
            string b = fg.rf();
            this.TextBox1.Text = b;
            string sqlcon = "server=lenovo-159d00cc;database=Dongman;uid=sa;pwd=123";
            string sqlIt = "select safeA from [Login] where [accountName]='" + b + "'";
            SqlConnection sql = new SqlConnection(sqlcon);
            sql.Open();
            SqlCommand cmd = new SqlCommand(sqlIt, sql);
            string g = cmd.ExecuteScalar().ToString();
            this.TextBox2.Text = g;        }
    }
此代码实现的是在页面载入时将上一个页面中输入的用户名带给本页中的Textbox1控件,并根据此用户名查询数据库找出与用户名对应的字段safeA的值,然后将此值显示在Textbox2控件上。但是实际运行时由前一页面载入此页时用户名没有带过来,而且如果不把后面查数据库的内容注释掉的话由前一页面载入时直接出现了“未将对象引用设置到对象的实例。”的错误。请问各位大侠哪里错了啊?如果要实现以上功能的话要怎么写啊?小弟我先谢谢了