I am working to discover how to work with a layered architecture, and I am running into a problem.
This is the code from my data layer:
using System.Data;
using System.Data.SqlClient;
namespace Datalaag_Class_Libary
{
public class Datalaag_Connectie_Class
{
public string ConnectionString = "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=master;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
SqlConnection con = new SqlConnection();
DataTable dt = new DataTable();
public DataTable Read()
{
con.ConnectionString = ConnectionString;
if (ConnectionState.Closed == con.State)
con.Open();
SqlCommand cmd = new SqlCommand("select * from demo_wedstrijdschema" , con);
try
{
SqlDataReader rd = cmd.ExecuteReader();
dt.Load(rd);
return dt;
}
catch
{
throw;
}
}
}
}
This is the code form the business layer:
using System.Data;
using Datalaag_Class_Libary;
namespace Businesslaag_Class_Libary
{
public class Busines_laag_class
{
public DataTable GetInfo()
{
try
{
Datalaag_Connectie_Class objdal = new Datalaag_Connectie_Class();
return objdal.Read();
}
catch
{
throw;
}
}
}
}
And this is the code from the user interface layer:
using System;
using System.Windows.Forms;
using Businesslaag_Class_Libary;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
Busines_laag_class test = new Busines_laag_class();
this.dataGridView1.DataSource = test.GetInfo();
}
catch
{
MessageBox.Show("error");
}
}
}
}
The program can run (not as it should run), but in the output screen the following error occurs:
Exception thrown: 'System.IO.FileNotFoundException' in Businesslaag_Class_Libary.dll
This is my full output screen:
The asked exception output:
Dont know what I have done wrong in the code. Can anyone help? Thanks in advance!