if (ds.Read())
{
 //有从库中读取值
}
else
{
//没有从库中读取值
}

解决方案 »

  1.   

    this.uidconn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnString"]);
    this.uidcom=new SqlCommand();
    uidcom.CommandText="select RYID,RYMC,RYGW,RYMM from [LZ_RYJGW] where RYID="+name.Text;
    uidcom.Connection=this.uidconn;
    uidcom.Connection.Open();
    SqlDataReader ds=uidcom.ExecuteReader();
    if(ds.Read())
    {
    string  PASS=ds["RYMM"].ToString();
    // Label7.Text=PASS+Label5.Text; if (pass.Text.Trim()==PASS.Trim())
    {
    cxw_s_ryid=ds["RYID"].ToString().Trim();
    System.Web.Security.FormsAuthentication.SetAuthCookie(name.Text,false);
    name.Text=ds["RYMC"].ToString();
    }
    else
    {
    Page.RegisterStartupScript("Wring!","<script>alert(\"密码错误,请检查!\");</script>");
    return;
    }
    } ds.Close();
    uidcom.Connection.Close();
    saucer(思归)你看有问题吗?
      

  2.   

    looks fine to me, but what about RYID, what's its datatype? if it is char/text, you should douidcom.CommandText="select RYID,RYMC,RYGW,RYMM from [LZ_RYJGW] where RYID='"+name.Text +"'";or you should check if name.Text is empty before doing the database operation