hi all ....
i want to use sqlhelperclass in my 3-tier architec. project. My company uses sqlhelper class and don't work on with DAL. so my question is how to use sqlhelperclass in DAL. My boss is saying i have not worked as per their req.How can i use the sqlhelperclass in following code and make my small proj. run.
code in BAL:
using Datalgc;
namespace Buss
{
public class BusinessLogic
{
public int Insert(string Name, DateTime DOB,string Addr,int phn,string Country,string State,string City)
{
BusinessLogic pDAL = new BusinessLogic();
try
{
return pDAL.Insert(Name,DOB , Addr ,phn ,Country,State,City);
}
catch
{
throw;
}
finally
{
pDAL = null;
}
}
}
}
also code in DAL:
using System.Data;
using DL;
namespace Datalgc
{
public class Class1
{
string connStr = ConfigurationManager.ConnectionStrings["spuserdetails"].ToString();
public int Insert(string Name, DateTime DOB, string Addr,int phno,string Country,string State,String City)
{
SqlHelper.
SqlConnection conn = new SqlConnection(connStr);
conn.Open();
SqlCommand Cmd = new SqlCommand("spuserdetails", conn);
Cmd.CommandType = CommandType.StoredProcedure;
try
{
Cmd.Parameters.AddWithValue("@Name", Name);
Cmd.Parameters.AddWithValue("@DOB", DOB);
Cmd.Parameters.AddWithValue("@Addr", Addr);
Cmd.Parameters.AddWithValue("@phno", phno);
Cmd.Parameters.AddWithValue("@Country", Country);
Cmd.Parameters.AddWithValue("@State", State);
Cmd.Parameters.AddWithValue("@City", City);
return Cmd.ExecuteNonQuery();
}
catch
{
throw;
}
finally
{
Cmd.Dispose();
conn.Close();
conn.Dispose();
}
}
}
}
code for code behind file:
using BAL;
public partial class _Default : System.Web.UI.Page
{
Class1 obj =new Class1();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
DropDownList1.ClearSelection();
DropDownList2.ClearSelection();
DropDownList3.ClearSelection();
}
protected void Button1_Click(object sender, EventArgs e)
{
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList3.DataSource =
DropDownList3.DataTextField = "City";
DropDownList3.DataValueField = "CityId";
DropDownList3.DataSource = form1;
DropDownList3.DataBind();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList2.DataSource = obj.ExecuteReader;
DropDownList2.DataTextField = "State";
DropDownList2.DataValueField = "StateId";
DropDownList2.DataSource = form1;
DropDownList2.DataBind();
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
TextBox2.Text = Calendar1.SelectedDate.ToString("dd/MM/yyyy");
}
protected void GridView1_SelectedIndexChanged(object sender, GridViewDeleteEventArgs e)
{
int personID = Int32.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString());
BusinessLogic pBAL = new BusinessLogic();
try
{
pBAL.Delete();
Label1.Text = "Record Deleted Successfully.";
}
catch (Exception ee)
{
Label1.Text = ee.Message.ToString();
}
finally
{
pBAL = null;
}
GridView1.EditIndex = -1;
GridView1.DataBind();
}
}
also in code behind page why
BusinessLogic pBAL = new BusinessLogic();
here businessLogic shows are you missing assembly ref. although i have added refrence in it. Any help will be highly appreciable. Thanks.