p
ublic bool Add(Liuyan refmodel)
{
string
SQL = "insert into liuyan(n
ame,phone,zhiw
ei,gongsi,addr,country,dianyou,content,adddate)values(@name,@phone,@zhiwei,@gongsi,@addr,@country,@dianyou,@content,@adddate)";
OleDbParameter[] parameters ={
new OleDbParameter("@name",OleD
BTy
PE.V
Archar),
new OleDbParameter("@tel",OleDbType.
VARChar),
new OleDbParameter("@zhiwei",OleDbType.VarChar),
new OleDbParameter("@gongsi",OleDbType.VarChar),
new OleDbParameter("@addr",OleDbType.VarChar),
new OleDbParameter("@country",OleDbType.VarChar),
new OleDbParameter("@dianyou",OleDbType.VarChar),
new OleDbParameter("@content",OleDbType.VarChar),
new OleDbParameter("@adddate",OleDbType.VarChar)
};
parameters[0].Value=model.Xingming;
parameters[1].Value=model.Tel;
parameters[2].Value=model.Zhiwei;
parameters[3].Value=model.Gongsi;
parameters[4].Value=model.Addr;
parameters[5].Value=model.Country;
parameters[6].Value=model.Dianyou;
parameters[7].Value=model.Content;
parameters[8].Value=model.Adddate;
return sqlHelper.executeCommand(sql, parameters);
}
//使用反射记得引用using
System.Reflection;命名空间
Type t = refmodel.GetType();
for (int i = 0; i < t.GetPRoperties().Length; i++)
{
parameters[i].Value= t.GetProperties()[i].GetValue(refmodel, null);
}