您的位置:首页 > 数据库

读取数据库中空字段的处理方法如下

2012-05-22 22:59 351 查看
#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控件不会对页面不局造成改动!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐