u014235180
2015-10-07 06:14 阅读 1.4k

ASP.net那个result上下文不存在 急急急....

SqlConnection lianjie = new SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=eShop;Integrated Security=True;");
SqlCommand shuru = new SqlCommand();
shuru.Connection = lianjie;
shuru.CommandType = CommandType.Text;
shuru.Parameters.Add("@姓名", SqlDbType.Char, 8).Value = TextBox1.Text.Trim();
shuru.Parameters.Add("@学号", SqlDbType.TinyInt).Value = TextBox2.Text.Trim();

    lianjie.Open();
    SqlDataReader druserinfo = shuru.ExecuteReader();
    result.Load(druserinfo);

    if (result.Rows.Count > 0)
    {
        Response.Write("OK");
        GridView1.DataSource = result;
    }
    else
    {
        Response.Write("Failure");
        GridView1.DataSource = null;
    }
}
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

相关推荐