简体   繁体   中英

Asp.net C# web service - oracle connection

I have written one web service for employee leave request.

It has 3 Web Services…

Two are connecting to SQL data source and 1 connecting to oracle DB.

Please note that the Oracle [Web method] for NOT even showing when run it on Browser whereas the other methods are invoked. Also note that I test this connecting setting and executed in asp. C# as a application method it works.

[WebMethod]       
public DataSet Leave_balance(string empNo)
{
    string oradb = "Data Source=hRPROD;UserId=HR;Password=hr;";
    //string oradb = "Data Source=(DESCRIPTION="
    //    + "(ADDRESS=(PROTOCOL=TCP)(HOST=esnaadhrsrv1)(PORT=1521))"
    //     + "(CONNECT_DATA=(SERVICE_NAME=hr1)));"
    //     + "User Id=hr;Password=hr;";
    OracleConnection conn = new OracleConnection();
    conn.ConnectionString = oradb;
    conn.Open();
    OracleCommand cmd = conn.CreateCommand();
    //cmd.CommandText = "Select * from emp_intranet_leave where reg_no='" + empNo + "'";
    cmd.CommandText = "Select * from emp_intranet_leave";
    cmd.ExecuteNonQuery();
    OracleDataAdapter adapter = new OracleDataAdapter(cmd);
    adapter.SelectCommand.Parameters.Add("emp_no", OracleType.Int32).Value = 2415;
    DataSet ds = new DataSet();
    adapter.Fill(ds);
    conn.Close();
    return (ds);
}

Instead of using dataset use class concept. trace whether data is retrieved from oracle database. if not getting data please check with your database connection. you can return data from webmethod either using list or string (xml) data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM