Monday, January 6, 2014

Get Hierarchy from SQL DATABASE Tables

CREATE PROCEDURE SP_Fin_Get_All_AccountHeads_Group_Hierarchy
    @Group VARCHAR(100),
    @CompID VARCHAR(100)
AS
---SP_Fin_Get_All_AccountHeads_Group_Hierarchy 'Admnistrative Expenses', 'ANOOS'
BEGIN
DECLARE    @primary_account_head_group_id VARCHAR(100)
DECLARE @MaxDepth INT
    DECLARE @CurrentFiscal VARCHAR(50)
    SET @MaxDepth = 6;   
   
    ;WITH LedgerList AS(
                    SELECT isnull(account_heads_parent_id,0) AS ParentId,
                            account_heads_id AS Id,       
                            account_heads_code AS Code,
                            description AS Description,   1 AS Hierarchy
                    FROM fin_account_heads
                    WHERE account_heads_parent_id is null
                    AND primary_account_head_group_id=(select account_heads_group_id    from               fin_account_heads_group where account_heads_group_name =@Group)
                    and company_code = @CompID
                    AND is_active=1
                   
                   UNION ALL

                    SELECT AH.account_heads_parent_id AS ParentId,
                            AH.account_heads_id AS Id,       
                            AH.account_heads_code AS Code,
                            AH.description AS Description,
                            LedgerList.Hierarchy + 1 AS Hierarchy
                    FROM fin_account_heads AH
                    INNER JOIN LedgerList
                                ON AH.account_heads_parent_id = LedgerList.ID
                    WHERE AH.company_code = @CompID
                            AND LedgerList.Hierarchy < @MaxDepth
                    AND is_active=1
                    )   
                    SELECT * FROM LedgerList                   
End

Populate TreeView From DataBase Using Recursive Function

Table Name: accountheads

IID Name ParentID
1 Test01 0
2 Test001 1
3 Test002 1
4 Test02 0
5 Test001 4
6 Test002 4
7 Test003 6


protected DataSet PDataset(string select_statement)
{
            SqlConnection _con = new SqlConnection("DataSource(Local); 
            database =DATABASE NAME ; UserID=sa;Password=******");
            SqlDataAdapter ad = new SqlDataAdapter(select_statement, _con);
            DataSet ds = new DataSet();
            ad.Fill(ds);
            _con.Close();
            return ds;
}


 public void Load_tree()
 {
            DataSet PrSet = PDataset("SELECT * FROM accountheads");
            treeView1.Nodes.Clear();
            foreach (DataRow dr in PrSet.Tables[0].Rows)
            {
                if ((int)dr["ParentID"] ==  0 )
                {
                    TreeNode tnParent = new TreeNode();
                    tnParent.Text = dr["Name"].ToString();
                    string value = dr["ID"].ToString();
                    tnParent.Expand();
                    treeView1.Nodes.Add(tnParent);
                    FillChild(tnParent, value);
                 }
             }
}

        public int FillChild(TreeNode parent,string ID)
        {

            DataSet ds = PDataset("SELECT * FROM tree WHERE ParentID =" + ID );
            if (ds.Tables[0].Rows.Count > 0)
            {

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    TreeNode child = new TreeNode();
                    child.Text = dr["Name"].ToString().Trim();
                    string temp = dr["ID"].ToString();
                    child.Collapse();
                    parent.Nodes.Add(child);
                    FillChild(child, temp);
                }
                return 0;
            }
            else 
            {
                return 0;
            }
                                                          
        }

Wednesday, December 18, 2013

The operation has timed out. While deploying SSRS


Check all following conditions:
----------------------------------

Step :1
  1. The connection string for the data source, which is - Connect Timeout=100
  2. Tools>Options>Database Tools>Query and View Designers. Cancel long running query is set to 100 or max 60000
  3. Tools>Options>Database Tools>Table and Database Designers>Checked 'Override Connection String time-out value for table designer updates. Transaction time-out after is set to 100 or max 60000
Step :2 
  1. Open your web browser on the server and go to http://localhost:80/Reports
  2. Navigate to the Report location and click on the problem report(s).
  3. On the left-hand pane, click on Properties.
  4. In the ‘Report Execution Timeout’ click the ‘Do not timeout report execution’. (via
Step:3

Set the HttpRuntime ExecutionTimeout
  1. Open the ReportServer’s Web.config file by going to Start -> Administrative Tools -> Internet Information Services.
  2. From there, expand Web Sites -> Default Web Site, and click on ReportServer. On the right-hand pane, right-click ‘Web.Config’ and select ‘Open’.
  3. Locate the HttpRuntime parameter. If it doesn’t exist, you will have to create it within the section.
  4. Set the executionTimeout value to ‘10800’ (3 hours) as shown below:

    
Step: 4
Tools>Options>Database Tools>Table and Database Designers> check the option  prevent saving changes that requires table re-creation 
step: 5 
also check your results by executing the procedure or SQLstatement


Wednesday, November 20, 2013

how to change en-US dates to en-GB for asp.net? ( M/d/yyyy to dd/MM/yyyy)

  • en-US: M/d/yyyy (e.g. 3/14/2012)
  • en-GB: dd/MM/yyyy (e.g. 14/03/2012)
 do the following in web.config file


<configuration/>
<system.web/>
<globalization culture="en-GB"/> 
</system.web>
</configuration> 
 
 

 

Friday, November 15, 2013

503 service unavailable IIS OR Application pool stops automatically in IIS7

SharePoint:
 
503 service unavailable:

application pool stops so you start the application pool of the web Application.

I got this error message when my application pool run with user Identity.

.Net:

1.you are given wrong user name or password you got this error message.

Do the following changes in application pool.

1.click on the application pool
2.click on advanced setting on the right pane.
3.click on Identity Under the process model.
4.select built in account under this user network(Ex:network service )
5.select custom account give user name and password


 

Wednesday, November 6, 2013

The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified

CASE 1: if you are used order by clause in the following view
SELECT  
  C.customer_id
, C.customer_code
, C.customer_type_id
A.mobile ,A.email , A.phone
FROM clinic_customers C INNER JOIN address_details A ON A.address_id=C.address_id
order by C.last_update_on desc

You got following error message

The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified

do small change above code as follows it is working fine
CASE 2: if you can use order by clause in the following view
SELECT   TOP 100 PERCENT 
  C.customer_id
, C.customer_code
, C.customer_type_id
A.mobile ,A.email , A.phone
FROM clinic_customers C INNER JOIN address_details A ON A.address_id=C.address_id
order by C.last_update_on desc

Tuesday, September 3, 2013

cannot use a leading .. to exit above the top directory

Solution 1

It means that one of the paths has a ".." at the beginning of it that would result in exiting the web site's root folder hierarchy. You need to google "asp.net relative paths" or something like that to help you with your problem.

BTW, a hint to where the problem is is included in the exception page that you saw. It will actually tell you what file it found the problem in.

To head off future occurences of this exception, do a search in the entire solution for this string: "../". If you find any of those in files in the root path of your web site, address them.