pulic DataSet getData(String sql)
{
using(SqlDataAdapter da=new SqlDataAdapter(sql,new SqlConnection(myConnectionString)))
{
DataSet ds=new DataSet();
da.Fill(ds);
return ds;
}
}
//猛档调镇茄用
String sql=“select * from myTable”枝旅乱;
DataSet ds=this.getData(sql);
///
/// 根据udl及执行语句,进行sql语句的执行
///
///
/// 档银凳
///
public DataSet QueryData(string strUdlFilePath, string SQLString)
{
using (OleDbConnection oleCon = new OleDbConnection("File Name =" + strUdlFilePath);)//连接数据库搏皮
{
using (OleDbCommand cmd = new OleDbCommand(SQLString, oleCon))//执行命令
{
using (OleDbDataAdapter sda = new OleDbDataAdapter(cmd))//返回到适配器
{
DataSet ds = new DataSet(); //填充到数据集
sda.Fill(ds);
行旅 oleCon.Dispose();
oleCon.Close();
return ds;
}
}
}
}
//udl文件内容
[oledb]
; Everything after this line is an OLE DB initstring
Provider=OraOLEDB.Oracle.1;Password=123;Persist Security Info=True;User ID=id;Data Source=ORAL