I’m trying to use my database to recover the information and use the Salary and the Employee’s name in a new windows form in visual studio, however and unfortunately the word Database is marking an error = “”Database does not contain a constructor that takes 0 arguments”” I don’t know how can I fix it, please help me, I am starting to learn c#
private void btnBuscar_Click(object sender, EventArgs e)
{
Impresion f = new Impresion();
f.Show();
int ID_Pagos = int.Parse(iD_PagosTextBox.Text);
using (SqlConnection connection = new Database().GetConnection()) << -- Here the error is marked -->>
{
connection.Open();
SqlCommand command = new SqlCommand("SELECT Empleado, Neto FROM Tabla_de_Pagos WHERE ID_Pagos = @ID_Pagos", connection);
command.Parameters.AddWithValue("@ID_Pagos", ID_Pagos);
SqlDataReader reader = command.ExecuteReader();
if (reader.Read())
{
string Empleado = reader["Nombre"].ToString();
decimal salario = (decimal)reader["Salario"];
}
}
}
New contributor
Rodolfo Laynez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.