I have got this SP to check whether the user is having any licenses that are stored in different tables..
I am getting results into dataset and from that dataset i am getting individual results with the count and if the count greater than zero then that user is having licenses.
This is the SP
ALTER PROCEDURE [dbo].[UserCheck]
(
@activatedBy varchar(30),
@brand varchar(20)
)
AS
BEGIN
DECLARE @acctId as BIGINT
SELECT @acctId = pk_acct_id from accounts with(nolock) where email = @activatedBy and brand = @brand
IF LEN(@acctId) > 1
BEGIN
SELECT count(*) from dbo.links with(nolock) where one = @acctId
union all
SELECT COUNT(*)FROM waveactivationinfo with(nolock) where Activated_by = @acctId
union all
SELECT COUNT(*) FROM ABCActivationInfo with(nolock) WHERE Activated_by = @acctId
union all
SELECT COUNT(*) FROM CSE_ActivationInfo with(nolock) WHERE activated_by = @acctId
union all
SELECT COUNT(*) FROM Connect_ActivationInfo with(nolock) WHERE activated_by = @acctId
union all
SELECT COUNT(*) FROM LicActivationInfo with(nolock) WHERE Activated_by = @acctId
END
END
GO
and then in DAL I am catching that results into dataset like this
public DataSet UserCheck(string strEmailID, string strBrand)
{
DataSet ds = new DataSet();
List<SqlParameter> ParaList = new List<SqlParameter>();
ParaList.Add(new SqlParameter("@activatedBy", strEmailID));
ParaList.Add(new SqlParameter("@brand", strBrand));
ds = SqlHelper.ExecuteDataset(new SqlConnection(ConfigurationManager.ConnectionStrings["DB"].ConnectionString), CommandType.StoredProcedure, "UserCheck", Convert.ToInt32(Utility.GetConfigValue("Connection_TimeOut")), ParaList.ToArray());
return ds;
}
I am retrieving that dataset in code behind like this ...
DataSet ds = userDeactivate.UserCheck(txtEmailID.Text.Trim(), brandType);
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
osCount = Int32.Parse(ds.Tables[0].Rows[0].ItemArray[0].ToString());
waveCount=Int32.Parse(ds.Tables[0].Rows[1].ItemArray[0].ToString());
aCount = Int32.Parse(ds.Tables[0].Rows[2].ItemArray[0].ToString());
PassCount = Int32.Parse(ds.Tables[0].Rows[3].ItemArray[0].ToString());
quickCount = Int32.Parse(ds.Tables[0].Rows[4].ItemArray[0].ToString());
vmcCount = Int32.Parse(ds.Tables[0].Rows[5].ItemArray[0].ToString());
}
}
I am thinking that this will not be a good way to check whether the user is having licenses .. Is there any alternatives for this
Is there any way to simply return the codes from SP for each result set .. if i want to get all counts from all queries do i need to modify any code in DAL ...
Aucun commentaire:
Enregistrer un commentaire