SqlConnection con = new SqlConnection(connectionstring);
con.Open();
DataSet ds1 = new DataSet();
SqlCommand cmd1 = new SqlCommand("select cl_id,cl_name,cl_accounts_email,cl_password,acst_id,us_id from CL_Clients where cl_id='" + DropDownList1.SelectedValue.ToString() + "'", con);
SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
da1.Fill(ds1);
con.Close();
I want to convert this code to 4 tier that is entity component webservice and presentation.Can any one help?Along with SqlQuery.
ziaulrahman
Member
483 Points
179 Posts
Converting single tier to 4 tier.
Apr 18, 2012 08:16 AM|LINK
SqlConnection con = new SqlConnection(connectionstring); con.Open(); DataSet ds1 = new DataSet(); SqlCommand cmd1 = new SqlCommand("select cl_id,cl_name,cl_accounts_email,cl_password,acst_id,us_id from CL_Clients where cl_id='" + DropDownList1.SelectedValue.ToString() + "'", con); SqlDataAdapter da1 = new SqlDataAdapter(cmd1); da1.Fill(ds1); con.Close();I want to convert this code to 4 tier that is entity component webservice and presentation.Can any one help?Along with SqlQuery.
Mark answer if it helps.
ignatandrei
All-Star
135073 Points
21662 Posts
Moderator
MVP
Re: Converting single tier to 4 tier.
Apr 18, 2012 09:40 AM|LINK
1. Make a class with cl_id,cl_name,cl_accounts_email and a Class derived from list< >
2. Load the class in a layer( repository)
3. Make a security layer
4. make a gui layer
ziaulrahman
Member
483 Points
179 Posts
Re: Converting single tier to 4 tier.
Apr 18, 2012 12:10 PM|LINK
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
alter PROCEDURE [dbo].[Getclientdetailsforproxy]
@var varchar(10)
AS
BEGIN
SELECT * from CL_Clients where cl_id=@var
END
GO
public static Clients getclientdetailsforproxy(string var)
{
Database db = new SqlDatabase(connectionstring);
DbCommand cmd = db.GetStoredProcCommand("[dbo].[Getclientdetailsforproxy]");
db.AddInParameter(cmd, "var", DbType.String, var);
DataSet ds = db.ExecuteDataSet(cmd);
Clients clintinfo = new Clients();
if (ds.Tables[0].Rows.Count > 0)
{
clintinfo.Cl_id = ds.Tables[0].Rows[0]["cl_id"].ToString();
clintinfo.Acst_id = Convert.ToInt32(ds.Tables[0].Rows[0]["acst_id"].ToString());
clintinfo.Cl_name = ds.Tables[0].Rows[0]["cl_name"].ToString();
clintinfo.Cl_password = ds.Tables[0].Rows[0]["cl_password"].ToString();
clintinfo.Cl_orderer_email = ds.Tables[0].Rows[0]["cl_orderer_email"].ToString();
clintinfo.Us_id = Convert.ToInt32(ds.Tables[0].Rows[0]["us_id"]);
}
return clintinfo;
}
Mark answer if it helps.