public dataview ewdataviewlink(string sconn, string stable/*表名*/, string slnkfld, string sdispfld, string sdispfld2, string sfilterfld, string sorderby/*排序列*/, string sordertype/*排序规则*/, bool bdistinct/*是否剔除重复值*/, string sfilter) { string ssql; try {
// create a new connection object using the connection string sqlconnection oconn = new sqlconnection(sconn); 【程序编程相关:失去信心?还是再度迷惘(二)——Mono】
// construct sql statement ssql = "select"; if (bdistinct) { ssql += " distinct"; } ssql += " [" + slnkfld + "], [" + sdispfld + "]"; if (sdispfld2 != "") { ssql += ", [" + sdispfld2 + "]"; } if (sfilterfld != "") { ssql += ", [" + sfilterfld + "]"; } ssql += " from [" + stable + "]"; if (sfilter != "") { ssql += " where " + sfilter; } if (sorderby != "") { ssql += " order by [" + sorderby + "] " + sordertype; } 【推荐阅读:March Library中的Multi】
// create a new dataset object to fill with data dataset ods = new dataset(); 【扩展信息:深入宠物店PetShop-SQLServ】
// create a new dataadapter using the connection object and sql statement sqldataadapter oda = new sqldataadapter(ssql, oconn);
// fill the dataset with data from the dataadapter object oda.fill(ods, "ewdataset");
... 下一页