引用:using Kingdee.BOS.ServiceHelper;
示例:
private void GetInfoComId(string fid, out string formId, out string paramFormId, out string name)
{
/*1. Select语句*/
string strSQL = string.Format("select t0.finfocomparamid,t0.finfocomid ,t1.fname\r\nfrom t_bas_infocomreg t0 left Join t_bas_infocomreg_l t1 on t0.fid=t1.fid and t1.flocaleid=2052\r\nwhere fnumber='{0}'", fid);
/* 2.DB 操作 :DBServiceHelper.ExecuteDataSet 详情请看下面*/
DataSet dataSet = DBServiceHelper.ExecuteDataSet(base.Context, strSQL);
/*3.对查询结果进行校验*/
if (dataSet != null && dataSet.Tables.Count > 0)
{
/*4.注意类型转换*/
formId = (dataSet.Tables[0].Rows[0]["finfocomid"] as string);
paramFormId = (dataSet.Tables[0].Rows[0]["finfocomparamid"] as string);
name = (dataSet.Tables[0].Rows[0]["fname"] as string);
return;
}
string text;
name = (text = "");
string text2;
paramFormId = (text2 = text);
formId = text2;
}
-----------------------------------------------------------------------------------------------
以下是DBServiceHelper.ExecuteDataSet方法的实现,我们不用过分关心此方法如何实现,直接引用【Kingdee.BOS.ServiceHelper.DBServiceHelper】使用即可。
// Kingdee.BOS.ServiceHelper.DBServiceHelper
public static DataSet ExecuteDataSet(Context ctx, string strSQL)
{
IDBService dBService = ServiceFactory.GetDBService(ctx);
DataSet result;
try
{
DataSet dataSet = dBService.ExecuteDataSet(ctx, strSQL);
ServiceFactory.CloseService(dBService);
result = dataSet;
}
finally
{
ServiceFactory.CloseService(dBService);
}
return result;
}
推荐阅读