WebService - pasing parameter

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
kurtbilde
Posts: 113
Joined: Wed 16 Mar 2005 16:02
Location: Odense, Denmark

WebService - pasing parameter

Post by kurtbilde » Mon 01 Jul 2013 17:23

Hi,

Having this code

Code: Select all

[WebMethod]
  public DataSet GetRowsById(int ROWValue_ID) {
    try {
            connection = new OracleConnection(ConfigurationManager.ConnectionStrings["ProviderService"].ConnectionString);
            dataAdapter = new OracleDataAdapter("", connection);
            dataAdapter.SelectCommand.CommandType = CommandType.Text;
            dataAdapter.SelectCommand.CommandText = "SELECT ROWValue_ID, TEXT_DK, TEXT_UK FROM Table WHERE (ROWValueID=:RowvalueId) AND (OWNER_ID=3)";
            dataAdapter.SelectCommand.Parameters.Add("RowvalueId",OracleDbType.Integer).OracleValue = ROWValue_ID;
            dataAdapter.SelectCommand.Parameters["RowvalueId"].Direction = ParameterDirection.Input;
            dataAdapter.Fill(dataSet);
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
        finally
        {
          if (connection != null)
              connection.Close();
        }
        return dataSet;
    }
It makes Server error 500 when I envokes with a simple int (f.ex. 58) - it drives me nuts... I think it's the way I assign the parameter that causes the matter...

-Kurt

kurtbilde
Posts: 113
Joined: Wed 16 Mar 2005 16:02
Location: Odense, Denmark

Re: WebService - pasing parameter

Post by kurtbilde » Mon 01 Jul 2013 17:38

Sorry - just solved it...

Code: Select all

[WebMethod]
  public DataSet GetRowsById(int ROWValue_ID) {
    try {
            connection = new OracleConnection(ConfigurationManager.ConnectionStrings["ProviderService"].ConnectionString);
            dataAdapter = new OracleDataAdapter("", connection);
            dataAdapter.SelectCommand.CommandType = CommandType.Text;
            dataAdapter.SelectCommand.CommandText = "SELECT ROWValue_ID, TEXT_DK, TEXT_UK FROM Table WHERE (ROWValueID=:RowvalueId) AND (OWNER_ID=3)";

OracleParameter param1 = dataAdapter.SelectCommand.CreateParameter();
            param1.DbType = System.Data.DbType.Int32;
            param1.Direction = System.Data.ParameterDirection.Input;
            param1.ParameterName = "RowvalueId";
            param1.Value = Rowvalue_ID;
            dataAdapter.SelectCommand.Parameters.Add(param1); 

dataAdapter.Fill(dataSet);
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
        finally
        {
          if (connection != null)
              connection.Close();
        }
        return dataSet;
    }
Sorry!!!!!

-Kurt

Post Reply