locked
Why does not return 1 - RRS feed

  • Question

  • User-909867351 posted

    Hi

    Please look at this piece of code:

    SqlDataSource3.SelectParameters.Clear();
            SqlDataSource3.SelectCommand = "select  IFNULL(max(id) as maior,1) from correspondencia";
            SqlDataSource3.DataBind();
            DataView dvsqllist = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
            System.Data.DataView dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
            DataTable tablelist = dvsqllist.Table;
            Response.Write(tablelist.Rows[0]["maior"].ToString());

    Why I got error (not record at postion 0)

    Thank you

    Saturday, December 14, 2019 2:31 PM

Answers

  • User-909867351 posted

    Sorry, The code is wrong

    There is the correct code

      string maior="";
            SqlDataSource3.SelectParameters.Clear();
            SqlDataSource3.SelectCommand = "select  IFNULL(max(id),1) as maior from correspondencia";
            SqlDataSource3.DataBind();
           
            DataView dvsqllist = (DataView)SqlDataSource3.Select(DataSourceSelectArguments.Empty);
            DataTable tablelist = dvsqllist.Table;
            SqlDataSource3.DataBind();
            foreach (DataRow row in tablelist.Rows)
            {
                maior = row["maior"].ToString();
            }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 14, 2019 2:42 PM