zoukankan      html  css  js  c++  java
  • 读取数据库中空字段的处理方法如下

    #region 查询所有的产品信息

            /// <summary>

            /// 查询所有的产品信息

            /// </summary>

            /// <returns></returns>

            public List<Product> QueryAllProductInfo()

            {

                List<Product> productShowList = new List<Product>();

                Product product = null;

                string sql = " use QiGuang select * from Product ";

                try

                {

                    DataTable table = DBHelper.GetDataSet(sql);

                    foreach (DataRow row in table.Rows)

                    {

                        product = new Product();

                        product.Id =(int)row["Id"];

                        product.ISBN = row.IsNull("ISBN")? "":(string)row["ISBN"];

                        product.ScreenSize = row.IsNull("ScreenSize") ? "" : (string)row["ScreenSize"];

                        product.ProcessType = row.IsNull("ProcessType") ? "" : (string)row["ProcessType"];

                        product.WorkSystem = row.IsNull("WorkSystem") ? "" : (string)row["WorkSystem"];

                        productShowList.Add(product);

                    }

                    return productShowList;

                }

                catch (Exception e)

                {

                    Console.WriteLine(e.Message);

                    throw e;

                }

            }

            #endregion

     

    #region 查询所有的关博览胜列表

            /// <summary>

            /// 查询所有的关博览胜列表

            /// </summary>

            /// <returns></returns>

            public static List<NwebCn_rddtSortModel> GetAllNwebCn_rddtSortModelInfo()

            {

                List<NwebCn_rddtSortModel> list = new List<NwebCn_rddtSortModel>();

                NwebCn_rddtSortModel rddtSort = null;

                string sql = "select * from NwebCn_rddtSort ";

                OleDbDataReader reader = DBHelper.ExecuteReader(sql);

                while (reader.Read())

                {

                    rddtSort = new NwebCn_rddtSortModel();

                    rddtSort.ID = Convert.ToInt32(reader[0].ToString());

                    rddtSort.SortNameSi = reader[1].ToString();

                    rddtSort.SortNameTr = reader[2].GetType() == null ? "" : reader[2].ToString();

                    rddtSort.SortNameEn = reader[3].GetType() == null ? "" : reader[3].ToString();

                    rddtSort.ViewFlagSi = reader[4].ToString() == "True" ? true : false;

                    rddtSort.ViewFlagTr = reader[5].ToString() == "True" ? true : false;

                    rddtSort.ViewFlagEn = reader[6].ToString() == "True" ? true : false;

                    list.Add(rddtSort);

                }

                reader.Close();

                reader.Dispose();

                return list;

            }

    #endregion

     

    2.DataList和Repeater控件的区别:DataList控件布局容易是页面混乱,而Repeater控件不会对页面不局造成改动!

    作者:江宁织造
    博客:http://www.cnblogs.com/wgx0428/
  • 相关阅读:
    微信小程序上传文件(报错处理方式)
    自绘 TreeDataView 控件
    C# 读取outlook 本地签名
    【英雄帖】FreeRedis 邀请您一起优化项目。
    (30)ASP.NET Core3.1 集成Apollo快速安装与使用
    C#引用fo-dicom读取dicom文件异常
    .NET 开源导入导出库 Magicodes.IE 2.5发布
    WinUI 3 Preview 3 发布了,再一次试试它的性能
    Aspose.Word for DotNet 定位到每页,画笔 移动到某页。
    .NET Core下好用的FTP框架 FluentFTP
  • 原文地址:https://www.cnblogs.com/wgx0428/p/2514002.html
Copyright © 2011-2022 走看看