public partial class WebForm1 : System.Web.UI.Page
    {
       OleDbConnection con = new OleDbConnection("Server=.; Database = Student; Trusted_Connection = Yes");

(problem show and arrow on yes and said

Exception thrown: 'System.ArgumentException' in System.Data.dll

Additional information: An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;'.

i also connect database but result is same

protected void Page_Load(object sender, EventArgs e)
            {
                LoadGridview();
            }
        public void LoadGridview()
        {
            OleDbDataAdapter da = new OleDbDataAdapter("Select * FROM Student", con);
            DataSet ds = new DataSet();
            int n = da.Fill(ds);
            if (n > 0)
            {
                GridView1.Visible = true;
                GridView1.DataSource = ds;
                GridView1.DataBind();
                lbl_error.Text = "";
            }
        }

        protected void txt_get_data_in_grid_TextChanged(object sender, EventArgs e)
        {
            string query = "select * from student where names like'" + txt_get_data_in_grid + "%'";
            OleDbDataAdapter dal = new OleDbDataAdapter(query , con);
            DataSet ds1 = new DataSet();
            int n1 = dal.Fill(ds1);
            if(n1 > 0)
            {
                GridView1.Visible = true;
                GridView1.DataSource = ds1;
                GridView1.DataBind();
                lbl_error.Text = "";
            }
            else
            {
                if(n1==0)
                {
                    GridView1.Visible = false;
                    lbl_error.Text = "No Record Found......";
                }
                else
                {
                    LoadGridview();
                }
            }
        }
    }
}

Related posts

Recent Viewed