69 lines
1.9 KiB
C#
69 lines
1.9 KiB
C#
using Oracle.ManagedDataAccess.Client;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Text;
|
|
|
|
namespace HHWMS.Web
|
|
{
|
|
public class OracleHelper
|
|
{
|
|
public static OracleCommand cmd = null;
|
|
public static OracleConnection conn = null;
|
|
|
|
//user id=guest;password=guest123; data source=202.101.164.132:15555/SAGEX3;
|
|
public static string connstr = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=202.101.164.132)(PORT=15555))(CONNECT_DATA=(SERVICE_NAME=SAGEX3)));User Id=guest;Password=guest123";
|
|
|
|
public static OracleConnection init()
|
|
{
|
|
try
|
|
{
|
|
conn = new OracleConnection(connstr);
|
|
if (conn.State != ConnectionState.Open)
|
|
{
|
|
conn.Open();
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new Exception(e.Message.ToString());
|
|
}
|
|
return conn;
|
|
}
|
|
|
|
public static DataSet GetDataSet(string sqlstr)
|
|
{
|
|
DataSet set = new DataSet();
|
|
try
|
|
{
|
|
init();
|
|
OracleDataAdapter adp = new OracleDataAdapter(sqlstr, conn);
|
|
adp.Fill(set);
|
|
conn.Close();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new Exception(e.Message.ToString());
|
|
}
|
|
return set;
|
|
}
|
|
|
|
public static int ExecuteNonQuery(string cmdText)
|
|
{
|
|
int count;
|
|
try
|
|
{
|
|
init();
|
|
cmd = new OracleCommand(cmdText, conn);
|
|
count = cmd.ExecuteNonQuery();
|
|
conn.Close();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message.ToString());
|
|
}
|
|
return count;
|
|
}
|
|
}
|
|
}
|