在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
using System;
protected object AssembleObject(Type type, System.Data.IDataReader reader) if (o == null) System.Reflection.PropertyInfo[] properties = type.GetProperties();//声明一个获取类型属性的变量 for (int i = 0; i <reader.FieldCount; i++) if (val != DBNull.Value && property != null && property.CanWrite)//判断对象是否为空,属性是否为空,属性是否可写!如果都为true return o;
public int Id public string Name public int Sex public string SId public string Pwd
private void button1_Click(object sender, EventArgs e) using (OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|db2.mdb;Persist Security Info=True")) OleDbCommand cmd = new OleDbCommand("select * from db2.User", conn); OleDbDataAdapter da = new OleDbDataAdapter(cmd); dt = ds.Tables[0]; OleDbDataReader dr = cmd.ExecuteReader(); User u=new User(); }
|
请发表评论