日期:2014-05-17 浏览次数:20435 次
// 可指定连接字符串执行SQL并获取结果
public string getConnResult(string ConnStr,string strSQL,int nCol)
{
string strResult = "";
try
{
// 连接数据库
OracleConnection conn = new OracleConnection(ConfigurationManager.ConnectionStrings[ConnStr].ConnectionString);
OracleDataReader oradr;
OracleCommand oracmd;
oracmd = new OracleCommand(strSQL, conn);
conn.Open();
// 执行命令
oradr = oracmd.ExecuteReader();
// 读取内容
if (oradr.Read())
{
strResult = oradr[nCol].ToString();
}
// 关闭数据库
oradr.Close();
conn.Close();
}
catch
{
}
return strResult;
}
showText = DBControl.getConnResult("DZCXYH","select distinct to_lob(sgzj),wgrq,jh from dda02 where wgrq=(select distinct max(wgrq) from dda02 where jh='" + wellName + "') and jh='" + wellName + "'",0);
select sgzj,wgrq,jh from dda02 where wgrq=(select max(wgrq) from dda02 where jh='8B102') and jh='8B102'