没有得到完整的表,如果我给出行,只获得特定的行[1] [英] Not Getting Complete Table , Getting Only Particular Row If I Give Rows[1]

查看:49
本文介绍了没有得到完整的表,如果我给出行,只获得特定的行[1]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public partial class forgotpwd : System.Web.UI.Page
{
    ADO objado = new ADO();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        DataSet ds = objado.getpwd();
        if (TextBox1.Text == ds.Tables[0].Rows[0]["email"].ToString())
        {
            Label1.Text = ds.Tables[0].Rows[0]["password"].ToString();
        }


    }
}

推荐答案

首先计算表中存在的行数 ds.Tables [0] .Rows.Count



然后使用循环

First count the number of rows present in the table ds.Tables[0].Rows.Count

And then use loop
for(int i=0;i<ds.tables[0].rows.count;i++)>
{
if (TextBox1.Text == ds.Tables[0].Rows[i]["email"].ToString())
        {
            Label1.Text = ds.Tables[0].Rows[i]["password"].ToString();
        }
}


这篇关于没有得到完整的表,如果我给出行,只获得特定的行[1]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆