protected void Button1_Click(object sender, EventArgs e) { conn.Open(); MySqlCommand cmd = conn.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from serviceprovider"; cmd.ExecuteNonQuery(); DataTable dtt = new DataTable(); MySqlDataAdapter daa = new MySqlDataAdapter(cmd); daa.Fill(dtt); GridViews.DataSource = dtt; GridViews.DataBind(); conn.Close(); }
private void BindGrid() { SqlConnection con = new SqlConnection(dbConnectionString); SqlCommand cmd = new SqlCommand("Employees"); con.Open(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "spEmployeesProcedure"; cmd.Parameters.AddWithValue("@Action", "SELECT"); cmd.Parameters.AddWithValue("@Id", 509); cmd.Parameters.AddWithValue("@User_name", "Nara"); cmd.Parameters.AddWithValue("@Department", "Hr"); cmd.Parameters.AddWithValue("@MngerId", 500); SqlDataAdapter dataAdapter = new SqlDataAdapter(); cmd.Connection = con; dataAdapter.SelectCommand = cmd; DataSet dt = new DataSet(); dataAdapter.Fill(dt); GridViews.DataSource = dt.Tables[0]; GridViews.DataBind(); }