I have 2 existing functions. One I can't edit (getServiceNames) and in the second I need to set a string (getDataTableOne). I want to set this string with a function in the same class (getAllExceptNiServiceNames) but he gives me this error because my function i would like to edit is static.
An object reference is required non-static field, method, or property 'Queries.getAllExceptNiServiceNames()'
I can't remove the static property of the function and I also can't make a string object. Whats the best way to fix this?
public static DataSet getDataTableOne()
{
string serviceNameFilterLineThree = getAllExceptNiServiceNames(); //ERROR
}
public static DataSet getServiceNames()
{
DataSet ds = new DataSet();
string query_select = "select test";
ds = QualityGate.fillDataset(query_select);
return ds;
}
public string getAllExceptNiServiceNames()
{
string sql = "";
DataSet ds = getServiceNames();
int i = 0;
foreach (DataRow theRow in ds.Tables[0].Rows)
{
if (i != 0)
sql += "AND ";
sql += "serviceName = '" + theRow["serviceName"].ToString() + "' ";
i++;
}
return sql;
}