為了怕下次開新專案又要重新寫一次~還是在這稍微記錄一下好了
web.config
<add key="ConnectionString" value="server=XXXX;data source=XXX;user id=XXX;password=XXX"/>
程式方面
using System.Data.OracleClient;
using System.Data.OracleClient;
public DataSet SQlExecuteReader(string SQL)
{
DataSet ds = new DataSet();
try
{
OracleDataAdapter DReader = new OracleDataAdapter();
OracleConnection cn = new OracleConnection
(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]);
OracleCommand Cmd = new OracleCommand();
Cmd.CommandText = SQL;
Cmd.Connection = cn;
cn.Open();
DReader = new OracleDataAdapter(Cmd);
cn.Close();
DReader.Fill(ds);
}
catch (Exception ex)
{
cn.Close();
}
return ds;
}
沒有留言:
張貼留言