Asp.Net

Tuesday, 20 August 2013

DAL Page

public bool logincheck(string str, SqlParameter[] param)
    {
        try
        {
            con.Open();
            cmd = new SqlCommand(str, con);
            cmd.CommandType = CommandType.StoredProcedure;
            foreach (SqlParameter par in param)
            {
                cmd.Parameters.Add(par);
            }
            dr = cmd.ExecuteReader();
            if (dr.HasRows)
            {
                return true;
            }
            else
            {
                return false;
            }

        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            con.Close();
        }
       
    }
    public bool createusers(string str, SqlParameter[] param)
    {
        try
        {
            con.Open();
            cmd = new SqlCommand(str, con);
            cmd.CommandType = CommandType.StoredProcedure;
            foreach (SqlParameter par in param)
            {
                cmd.Parameters.Add(par);
            }
            string user = Convert.ToString(cmd.ExecuteNonQuery());
            if (user.Length > 0)
            {
                return true;
            }
            else
            {
                return false;
            }

        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            con.Close();
        }
    }
    public DataSet getusers(string str, SqlParameter[] param)
    {
        try
        {
            con.Open();
            cmd = new SqlCommand(str, con);
            cmd.CommandType = CommandType.StoredProcedure;
            foreach (SqlParameter par in param)
            {

                cmd.Parameters.Add(par);
            }
            da.SelectCommand = cmd;
            da.Fill(ds);
            return ds;



        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            con.Close();
        }

No comments:

Post a Comment