data access class(DAL)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace DALWatsans
{
class DataAccess
{
public DataAccess()
{
}
#region example of data accessing
public DataSet Getdetails()
{
using (SqlConnection Conn = DBConn.GetDbConnection())
{
SqlCommand cmd = new SqlCommand("SP", Conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet dst = new DataSet();
adp.Fill(dst);
return dst;
}
}
public void SetDetails(string name, string address, string phn)
{
using (SqlConnection Conn = DBConn.GetDbConnection())
{
SqlCommand cmd = new SqlCommand("SP", Conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@s_name", name);
cmd.Parameters.AddWithValue("@s_address", address);
cmd.Parameters.AddWithValue("@s_phn", phn);
cmd.ExecuteNonQuery();
}
}
public DataSet getdtl2()
{
using (SqlConnection Conn = DBConn.GetDbConnection())
{
string sql = "SELECT * FROM student";
SqlCommand cmd = new SqlCommand(sql, Conn);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet dst = new DataSet();
adp.Fill(dst);
return dst;
}
}
#endregion
}
}
/////////////////////////////////
#region Get Item Search
public DataSet GetItemSearch(ArrayList parameters)
{
using (SqlConnection conn = DBConn.GetDbConnection())
{
try
{
SqlCommand cmd = new SqlCommand("usp_GetItemSearch", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@nvcSEARCH", parameters[0]);
cmd.Parameters.AddWithValue("@inItemCatID", parameters[1]);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet dtst = new DataSet();
adp.Fill(dtst);
return dtst;
}
catch (Exception)
{
throw;
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace DALWatsans
{
class DataAccess
{
public DataAccess()
{
}
#region example of data accessing
public DataSet Getdetails()
{
using (SqlConnection Conn = DBConn.GetDbConnection())
{
SqlCommand cmd = new SqlCommand("SP", Conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet dst = new DataSet();
adp.Fill(dst);
return dst;
}
}
public void SetDetails(string name, string address, string phn)
{
using (SqlConnection Conn = DBConn.GetDbConnection())
{
SqlCommand cmd = new SqlCommand("SP", Conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@s_name", name);
cmd.Parameters.AddWithValue("@s_address", address);
cmd.Parameters.AddWithValue("@s_phn", phn);
cmd.ExecuteNonQuery();
}
}
public DataSet getdtl2()
{
using (SqlConnection Conn = DBConn.GetDbConnection())
{
string sql = "SELECT * FROM student";
SqlCommand cmd = new SqlCommand(sql, Conn);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet dst = new DataSet();
adp.Fill(dst);
return dst;
}
}
#endregion
}
}
/////////////////////////////////
#region Get Item Search
public DataSet GetItemSearch(ArrayList parameters)
{
using (SqlConnection conn = DBConn.GetDbConnection())
{
try
{
SqlCommand cmd = new SqlCommand("usp_GetItemSearch", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@nvcSEARCH", parameters[0]);
cmd.Parameters.AddWithValue("@inItemCatID", parameters[1]);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet dtst = new DataSet();
adp.Fill(dtst);
return dtst;
}
catch (Exception)
{
throw;
}
}
}
0 comments:
Post a Comment