日期:2014-05-18  浏览次数:20725 次

详细信息的问题(急)
就是说大概显示客户的详细信息


protected void Page_Load(object sender, EventArgs e)
  {
  if (!IsPostBack)
  {
  string ConnectionString = "Data Source=192.168.0.251;Initial Catalog=NEOS;Persist Security Info=True;User ID=sa;Password=mathdev789";
  SqlConnection cn = new SqlConnection(ConnectionString);

  string str = "select projectName from [clientProject] where projectID='" + Request.QueryString["projectID"] + "'";
  SqlDataAdapter sda = new SqlDataAdapter(str, cn);
  DataSet dr = new DataSet();
  cn.Open();
  sda.Fill(dr);
  DataRow ds = dr.Tables[0].Rows[0];
  TextBox1.Text = Convert.ToString(ds["projectName"]);
  cn.Close();
  }
   
  }

运行完了后,错误出现在DataRow ds = dr.Tables[0].Rows[0];处,说:在位置0处没有任何行,但是数据库里确实是有数据的,这是怎么回事?

------解决方案--------------------
先在查询分析器里面确认Select projectName + 条件 ..有记录!!

你的DataSet返回为空