none
'Search.playersTableAdapter' is inaccessible due to its protection level RRS feed

  • Question

  • Good Day,

    I have two forms form1 with a DataGridView Control form 2:Search with a DetailsView control.On Form 1 with the Datagridview I have a a search  button and a textbox  that allows the user to specify a name  in a textbox .When the Search button is clicked, a search in the database is executed according to the name entered and the matching record should be displayed in the detailview on the Search form. when I execute my code I get the following errors on line 66. 'Search.playersTableAdapter' is inaccessible due to its protection level and 'Search.cricketDataSet' is inaccessible due to its protection level. Here is my code.

    Form1:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace Question_2
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void playersBindingNavigatorSaveItem_Click(object sender, EventArgs e)
            {
                this.Validate();
                this.playersBindingSource.EndEdit();
                this.tableAdapterManager.UpdateAll(this.cricketDataSet);
    
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                // TODO: This line of code loads data into the 'cricketDataSet.Players' table. You can move, or remove it, as needed.
                this.playersTableAdapter.Fill(this.cricketDataSet.Players);
    
            }
    
            private void totalButton_Click(object sender, EventArgs e)
            {
                // Declare vaariable for Total Batting Average.
                decimal totalBattingAverage;
    
                // Store the total batting average.
                totalBattingAverage = (decimal)this.playersTableAdapter.TotalBattingAverage();
    
                // Display message for average.
                MessageBox.Show("Total Batting Average: " + totalBattingAverage);
            }
    
            private void averageButton_Click(object sender, EventArgs e)
            {
                // Declare vaariable for the average Batting Average.
                decimal averageBattingaverage;
    
                // Store the average batting average.
                averageBattingaverage = (decimal)this.playersTableAdapter.AverageBattingAverage();
    
                // Display message for the average batting total.
                MessageBox.Show("Average Batting average: " + averageBattingaverage);
            }
    
            private void searchButton_Click(object sender, EventArgs e)
            {
                //string nm = searchTextBox.Text;
                Search fm = new Search();
    
                fm.playersTableAdapter.SearchByFirstname(fm.cricketDataSet.Players,searchTextBox.Text);
    
                fm.ShowDialog();
            }
    
            private void tabPage1_Click(object sender, EventArgs e)
            {
                // Sort first tab in descending order.
                this.playersTableAdapter.DescendingOrder(this.cricketDataSet.Players);
            }
    
            private void tabPage2_Click(object sender, EventArgs e)
            {
                this.playersTableAdapter.FillByLess50(this.cricketDataSet.Players);
            }
    
           
        }
    }
    
    Is there a way I can fix this
    Monday, October 29, 2018 8:32 AM

Answers

  • You need to make playersTableAdapter in the Search class public.
    • Marked as answer by kgosi_mocumi Monday, October 29, 2018 11:16 AM
    Monday, October 29, 2018 10:00 AM
  • Try changing Modifiers property from Private to Public.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by kgosi_mocumi Monday, October 29, 2018 11:15 AM
    Monday, October 29, 2018 10:03 AM
    Moderator

All replies

  • You need to make playersTableAdapter in the Search class public.
    • Marked as answer by kgosi_mocumi Monday, October 29, 2018 11:16 AM
    Monday, October 29, 2018 10:00 AM
  • Try changing Modifiers property from Private to Public.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by kgosi_mocumi Monday, October 29, 2018 11:15 AM
    Monday, October 29, 2018 10:03 AM
    Moderator