How to send the value by session variable using Dataset....
Here i am using two table in one stored procedure
ALTER proc [dbo].[SP_SessionByDataset]
@fname varchar(20),
@pwd varchar(20),
@Email varchar(30)
as
select *from reg where fname=@fname and pwd=@pwd
select *from tblPerson where Email=@Email
GO
in Data Access Layer, i have written like this...
public DataSet SessionDataset(string FN,string PWD,string EMAIL)
{
con.Open();
cmd = new SqlCommand("SP_SessionByDataset", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@fname",FN);
cmd.Parameters.AddWithValue("@pwd",PWD);
cmd.Parameters.AddWithValue("@Email",EMAIL);
da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
con.Close();
return ds;
}
In Business Logic Layer,i have written like this...
public DataSet SessionDataset(string FN, string PWD, string EMAIL)
{
DataSet ds = d.SessionDataset( FN,PWD,EMAIL);
return ds;
}
In Application Layer how to do i achieved the task by using DataSet...
Here i have attached the coding rendered by DataTable which is used in some other coding...
Likewise i have to do the task for above code by using Dataset...
protected void Btn_Login_Click(object sender, EventArgs e)
{
LblMessage.Visible = false;
try
{
DAL d = new DAL();
DataTable dt = null;
DataSet ds = new DataSet();
//if(ds.Tables[0].Rows[0]["fn"]
dt = d.checkdata(txt_UName.Text.Trim(),txt_Pwd.Text.Trim());
if (dt.Rows.Count > 0 && txt_Pwd.Text.ToString() == dt.Rows[0][3].ToString())
{
Session["CustomerId"] = dt.Rows[0][0].ToString();
Session["CustomerName"] = dt.Rows[0][1].ToString();
Session["MobileNo"] = dt.Rows[0][2].ToString();
Session["UserType"] = dt.Rows[0][16].ToString();
if (dt.Rows[0][15].ToString() != "")
{
Session["CustomerTypeId"] = dt.Rows[0][15].ToString();
}
else
{
Session["CustomerTypeId"] = Session["CustomerId"].ToString();
}
Session["FullName"] = dt.Rows[0][4].ToString() + " " + dt.Rows[0][5].ToString();
Response.Redirect("CascadingDDL.aspx", true);
}
else
{
LblMessage.Visible = true;
LblMessage.ForeColor = System.Drawing.Color.Red;
LblMessage.Text = "Invalid Login Credentials";
}
}
catch (Exception ex)
{
LblMessage.Visible = true;
LblMessage.ForeColor = System.Drawing.Color.Red;
LblMessage.Text = ex.Message.ToString();
}
}
}