I am trying to fix an error I am getting in the code below line 34 and 35.
aliq.ALIQUOT_ID = reader["ALIQUOT_ID"].Equals();
aliq.SAMPLE_ID = reader["SAMPLE_ID"].Equals();
Both Aliquot_ID and Sample_ID are integers. However, the way I wrote those lines I am getting the following error:
Error 1 No overload for method 'Equals' takes '0' arguments C:...App_Code\DAL\DAL.cs 34.
Error 2 No overload for method 'Equals' takes '0' arguments C:...App_Code\DAL\DAL.cs 35.
How should I write these two lines in order to fix this issue.
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Oracle.DataAccess.Client;
namespace Data
{
/// <summary>
/// Summary description for DAL
/// </summary>
public class DAL
{
public static Model.Aliquot GetAliquot_ID(int aliqID)
{
string cs = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
OracleConnection conn = null;
OracleDataReader reader = null;
try
{
conn = new OracleConnection(cs);
string oracle = "SELECT SAMPLE_ID, ALIQUOT_ID, MATRIX_TYPE FROM LIMS.ALIQUOT WHERE ALIQUOT_ID = '" + aliqID + "'";
OracleCommand cmd = new OracleCommand(oracle, conn);
conn.Open();
reader = cmd.ExecuteReader();
reader.Read();
Model.Aliquot aliq = new Model.Aliquot();
aliq.ALIQUOT_ID = reader["ALIQUOT_ID"].Equals();
aliq.SAMPLE_ID = reader["SAMPLE_ID"].Equals();
aliq.MATRIX_TYPE = reader["MATRIX_TYPE"].ToString();
return aliq;
}
catch (Exception exp)
{
//Add Logging
HttpContext.Current.Trace.Warn("Error", "Error in GetAliquot_ID()", exp);
}
finally
{
if (reader != null) reader.Close();
if (conn != null && conn.State != ConnectionState.Closed) conn.Close();
}
return null;
}
}
Equals() doesn't make much sense in that context. What are you trying to do? Convert those results to int, right?
So instead of
aliq.ALIQUOT_ID =reader["ALIQUOT_ID"].Equals();
use
aliq.ALIQUOT_ID =Convert.ToInt32(reader["ALIQUOT_ID"]);