Rowshan Ali

Rowshan Ali

  • NA
  • 64
  • 143.1k

How to work by datatable from linq in asp.net .

Apr 10 2013 3:18 AM
hello dear
i m in problems . firstly i want to load data from database table or view named dt, then i want to search from dt without going to database ho can i solve it.

  DataTable dt = new DataTable();
    DataColumn d1 = new DataColumn("PIId");
    DataColumn d2 = new DataColumn("PINO");
    DataColumn d3 = new DataColumn("LCTRANDAte");
    private void mytable()
    {
        dt.Columns.Add(d1);
        dt.Columns.Add(d2);
        dt.Columns.Add(d3);

        using (SqlConnection conn = new SqlConnection(_connStr))
        {
            string sql = "SELECT PIId, PINo, L_CTransdate FROM PInvoice";
            using (SqlCommand cmd = new SqlCommand(sql, conn))
            {
                using (SqlDataAdapter ad = new SqlDataAdapter(cmd))
                {
                    ad.Fill(dt);
                }
            }
        }

i want to search it from dt in button click event.

if any body help me best regurds.



Answers (2)