读取数据库中空字段的处理方法如下
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控件不会对页面不局造成改动!
/// <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控件不会对页面不局造成改动!
相关文章推荐
- 从数据库中字段为byte的图片读取处理存入磁盘
- JAVA 处理时间 - java.sql.Date、java.util.Date与数据库中的Date字段的转换方法
- JAVA 处理时间 - java.sql.Date、java.util.Date与数据库中的Date字段的转换方法[转]
- JAVA 处理时间 - java.sql.Date、java.util.Date与数据库中的Date字段的转换方法
- 关于用ADO读取数据库中空字段的发现
- JAVA 处理时间 - java.sql.Date、java.util.Date与数据库中的Date字段的转换方法[转]
- C# 用数据库读取Excel出现“定义了过多字段”错误的解决方法 .
- C# 用数据库读取Excel出现“定义了过多字段”错误的解决方法
- 更新数据库所有表的某一个指定字段 ,附加对‘将 varchar 值转换为数据类型为 int 的列时发生语法错误’处理方法
- oralce数据库处理clob字段类型方法的介绍
- VC 处理数据库datetime字段的方法
- JAVA 处理时间 - java.sql.Date、java.util.Date与数据库中的Date字段的转换方法[转]
- C#程序连接数据库及读取数据库中字段的简单方法总结
- 数据库大字段的处理方法
- 【转载】C#连接数据库及读取数据库中字段的简单方法总结
- 数据库字段空值处理的方法
- JAVA 处理时间 - java.sql.Date、java.util.Date与数据库中的Date字段的转换方法
- JAVA 处理时间 - java.sql.Date、java.util.Date与数据库中的Date字段的转换方法[转]
- JAVA 处理时间 - java.sql.Date、java.util.Date与数据库中的Date字段的转换方法 转载自:
- C# 用数据库读取Excel出现“定义了过多字段”错误的解决方法