当前位置: 首页>>代码示例>>C#>>正文


C# OleDbDataReader.GetFloat方法代码示例

本文整理汇总了C#中System.Data.OleDb.OleDbDataReader.GetFloat方法的典型用法代码示例。如果您正苦于以下问题:C# OleDbDataReader.GetFloat方法的具体用法?C# OleDbDataReader.GetFloat怎么用?C# OleDbDataReader.GetFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.OleDb.OleDbDataReader的用法示例。


在下文中一共展示了OleDbDataReader.GetFloat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Page_Load

    protected void Page_Load(object sender, EventArgs e) {
        paramSexo = "";
        paramNome = "";
        try {
          paramSexo = Request["RadioButtonList1"];
          paramNome = Request["TextBox1"];
          if (paramSexo == null) paramSexo = "";
          if (paramNome == null) paramNome = "";
        }
        catch(Exception){};

        Label1.Text = "Registros encontrados:";
        String filtro1 = "", filtro2 = "";

        if (paramSexo.Equals("Todos")) {
                filtro1 = " TRUE ";
        }
        else if (paramSexo.Equals("Masculino")) {
                filtro1 = " (sexo='M') ";
        }
        else if (paramSexo.Equals("Feminino"))
        {
            filtro1 = " (sexo='F') ";
        }
        else
        {
            filtro1 = " FALSE ";
            Label1.Text = "";
        }

        filtro2 = " (nomeprof LIKE '%" + paramNome + "%') ";

        try {
          conexao = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/temp/Escola.mdb");
          conexao.Open();

          string sql = "select * from professores WHERE " 
              + filtro1 + " AND " + filtro2 + " ORDER BY nomeprof";
          stm = new OleDbCommand(sql, conexao);
          dr = stm.ExecuteReader();

          String strHTML = "";
          if (dr.HasRows) { //mostramos o cabeçalho da <table> somente se temos registros
              strHTML = "<TABLE name=profs border=1 width='65%'> <TR style='font-size: 14px; font-family: verdana; text-align: center; font-weight: 900; color: #009;'>" 
                  + "<TD>&nbsp;Código&nbsp;</TD><TD>&nbsp;Nome&nbsp;</TD>"
                  + "<TD>&nbsp;Sexo&nbsp;</TD><TD>&nbsp;Salário&nbsp;</TD></TR>";
          }

          while (dr.Read()) {
              int codigo = dr.GetInt16(0); //codprof
              String nome = dr.GetString(1); //nome
              String sexo = dr.GetString(2); //sexo
              float salario = dr.GetFloat(3); //salário
              strHTML += "<TR><TD style='font-size: 12px; font-family: verdana; text-align: center;'>" + codigo
                      + "</TD><TD style='font-size: 12px; font-family: verdana; text-align: left;'>&nbsp;&nbsp;"
                      + nome + "</TD><TD style='font-size: 12px; font-family: verdana; text-align: center;'>"
                      + sexo + "</TD><TD style='font-size: 12px; font-family: verdana; text-align: center;'>" 
                      + salario + "</TD></TR>";
          }

          strHTML += "</TABLE> <br/><br/><br/>";
          LiteralControl lc = new LiteralControl(strHTML);
          Panel2.Controls.Add(lc);
          stm.Dispose();
          dr.Close();
          conexao.Close();
        } catch (Exception exc) {
            Label1.Text = "Erro no processamento do BD - " + exc.Message;
        }
    }
开发者ID:rodrigogregorioneri,项目名称:Projetos-e-exercicios-faculdade,代码行数:70,代码来源:Consulta.aspx.cs


注:本文中的System.Data.OleDb.OleDbDataReader.GetFloat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。