zoukankan      html  css  js  c++  java
  • 把数据中的数据绑定到dataGridViewX1

    #region 把数据绑定到dataGridViewX1
    /// <summary>
    ///
    /// </summary>
    /// <param name="RiverName">河流名称</param>
    /// <param name="connString">数据库连接串</param>
    public void GetRiverString(string RiverName, string connString)
    {
    SqlConnection conn
    = null;
    try
    {
    conn
    = new SqlConnection(connString);
    conn.Open();
    string SqlStr = "SELECT ID, RIVERCODE, FDKZDMC, KZDHDGC, JSYJQJHC, JSYJHDPD,JSYJQJLYMJZA, JSYJQJLYMJYA, " +
    "KZDYSLYMJZA, KZDYSLYMJYA, KZDYSHC, KZDYSHDPD, LSZGSW, LSZGLL,LSZGSJ, BZ " +
    "FROM CC_RIVER_JHFDLYTZZ " +
    "WHERE (RIVERCODE ='" + RiverName + "')";
    SqlCommand cmd
    = conn.CreateCommand();
    cmd.CommandText
    = SqlStr;
    SqlDataAdapter da
    = new SqlDataAdapter(cmd);
    DataSet ds
    = new DataSet();
    da.Fill(ds);
    if (ds.Tables != null && ds.Tables[0].Rows != null)
    {
    foreach (DataRow dr in ds.Tables[0].Rows)
    {
    if (dr["LSZGSW"].ToString() != "")
    {
    dr[
    "LSZGSW"] = Decimal.Parse(dr["LSZGSW"].ToString()).ToString("0.00");

    }
    if (dr["LSZGLL"].ToString() != "")
    {
    dr[
    "LSZGLL"] = PublicMethod.ConvertEFigure(dr["LSZGLL"].ToString());
    }
    }
    dataGridViewX1.DataSource
    = ds.Tables[0].DefaultView;
    }
    }
    catch(Exception ex)
    {
    MessageBox.Show(ex.Message);
    }
    finally
    {
    conn.Close();
    }
    }
    #endregion
  • 相关阅读:
    vue-lazy-component
    vue修饰符sync
    vue-router-auto动态生成路由插件
    我的第一个WebAPI程序
    GitHub界面初识
    新闻API接口
    childNodes属性 和 nodeType属性
    接口测试总结
    网站被k
    js声明引入和变量声明和变量类型、变量
  • 原文地址:https://www.cnblogs.com/beeone/p/2097998.html
Copyright © 2011-2022 走看看