silentwolf
Active member
- Local time
- Today, 06:47
- Joined
- Jun 12, 2009
- Messages
- 644
Hi guys,
I am running into a problem in C# and hope someone could let me know how I would need to change following Code.
incosistent accessability: return type List<Person> GetPeople is less accessable then method 'DataAccess'.GetPeople.
This is a code Tim Corey did profide on a You Tube Tutorial. Unfortunatelly I get the Error but can't seam to work out where I would need to change the accessibility.
So maybe someone could tell me please?
Many thanks
Albert
I am running into a problem in C# and hope someone could let me know how I would need to change following Code.
incosistent accessability: return type List<Person> GetPeople is less accessable then method 'DataAccess'.GetPeople.
This is a code Tim Corey did profide on a You Tube Tutorial. Unfortunatelly I get the Error but can't seam to work out where I would need to change the accessibility.
So maybe someone could tell me please?
Code:
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapper;
namespace SonnenhausCSharpAndSQLServer
{
public class DataAccess
{
public List<Person> GetPeople(string lastName)
{
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal("Sonnehaus")))
{
var output = connection.Query<Person>($"SELECT * FROM Employees WHERE SurName = '{ lastName}'").ToList();
return output;
}
}
}
}
Code:
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 SonnenhausCSharpAndSQLServer
{
public partial class Dashboard : Form
{
List<Person> people = new List<Person>();
public Dashboard()
{
InitializeComponent();
UpdateBinding();
}
private void UpdateBinding()
{
peopleFoundListbox.DataSource = people;
peopleFoundListbox.DisplayMember = "FullInfo";
}
private void searchButton_Click(object sender, EventArgs e)
{
DataAccess db = new DataAccess();
people = db.GetPeople(lastNameText.Text);
UpdateBinding();
}
}
}
Many thanks
Albert