SqldataReader Reader=new SqldataReader 
Label.text=Reader["ID"];
label.text=Reader.GetString(0);在数据库中的字段位置。

解决方案 »

  1.   

    http://chs.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/howto/samples/adoplus/adooverview3/adooverview3.src
      

  2.   

    string sSql = "Select ID From Table";
    string sConn = "Data Source=(local);Initial Catalog=DB_Name;User ID=sa;Password=;Persist Security Info=False;"
    SqlConnection conn = new SqlConnection(sConn);
    SqlCommand cmd = new SqlCommand(sSql,conn);
    conn.open();
    try

        SqlDataReader dr = cmd.ExecuteReader();
        while(dr.read())
        {
            this.RegisterStartupScript("jsShowValue","<script language=javascript>alert('" + dr["ID"].toString() + "')</script>");
        }
        dr.close();
    }
    catch(SqlException ex)
    {
        this.RegisterStartupScript("jsShowErr","<script language=javascript>alert('" + ex.Message + "')</script>");
    }
    finally
    {
        conn.close();
    }