using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Data.SqlClient; using System.Data; namespace Management.DAL { class DataAccessLayer { SqlConnection SqlConnection; public DataAccessLayer() { SqlConnection = new SqlConnection("server=MOHAMED; database=product_DB; Integrated Securit=true"); } public void open() { if(SqlConnection.State != ConnectionState.Open) { SqlConnection.Open(); } } public void Close() { if(SqlConnection.State==ConnectionState.Open) { SqlConnection.Close(); } } public DataTable SelectData(string stored_procedure, SqlParameter[] param) { SqlCommand sqlcmd = new SqlCommand(); sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.CommandText = stored_procedure; if(param !=null) { for(int i = 0; i < param.length; i++) { sqlcmd.Parameters.Add(param[i]); } } SqlDataAdapter da = new SqlDataAdapter(sqlcmd); DataTable dt = new DataTable(); da.Fill(dt); return dt; } public void ExecuteCommand(string stored_procedure, SqlParameter[] param) { SqlCommand sqlcmd = new SqlCommand(); sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.CommandText = stored_procedure; if (param !=null) { sqlcmd.Parameters.AddRange(param); } sqlcmd.EndExecuteNonQuery(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)