locked
Error - Operator > cannot be applied to operands of type string and int RRS feed

  • Question

  • User-1499457942 posted

    Hi

     DataSet ds = SqlDbOperation.DataRecords("Select * from test");
    
                        if (ds.Tables[0].Rows.Count.ToString() > 0)
                        {
                        }
    
    
    public static DataSet DataRecords(string SrcSql, SrcType SourceType = SrcType.SqlQuery)
            {
                DataSet ds = new DataSet();
                SqlDataAdapter da = new SqlDataAdapter(SrcSql, ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
                da.Fill(ds);
                return ds;
            }

    Thanks

    Wednesday, November 21, 2018 9:33 AM

Answers

  • User753101303 posted

    Hi,

    You are using converting the Count to a string and try to compare this string to an integer. Just delete the .ToString() call :

    if (ds.Tables[0].Rows.Count > 0) // etc...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 21, 2018 10:17 AM