Results 1 to 2 of 2

Thread: How to display the result of this code into a table ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2018
    Posts
    81

    How to display the result of this code into a table ?

    Hi there,
    I have written this code and now I want to put show its result in a table .
    The code is
    Code:
    $sql='SELECT id , fname , reg_date ,
    CONCAT("Registerd ", DATEDIFF(CURDATE(), reg_date), " Days Age.")
    AS RegisteredSence 
    FROM users;
    Any idea?

  2. #2

    Re: How to display the result of this code into a table ?

    Hii Max45,

    If you want to display the results of a query in a table, I recommend Ado.net.

    Try this code...

    Code:
    <asp:GridView ID="GridView1" runat="server"></asp:GridView>
    string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
                string query = "";
                using (SqlConnection con = new SqlConnection(constr))
                {
                    using (SqlDataAdapter sda = new SqlDataAdapter(query, con))
                    {
                        using (DataTable dt = new DataTable())
                        {
                            sda.Fill(dt);
                            GridView1.DataSource = dt;
                            GridView1.DataBind();
                        }
                    }
                }
    I hope it will helpful to you!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width