Solved

line continuation in asp.net markup

Posted on 2012-03-14
5
644 Views
Last Modified: 2012-03-18
Hello experts,
I have a very long sql in my asp.net markup like this. What line continuation character do I use? The compiler says "if this attribute value is enclosed in quotation marks, the quotation marks must match."

            <asp:SqlDataSource ID="sdsBonuses" runat="server" 
                ConnectionString="<%$ ConnectionStrings:AdHocReportingConnectionString %>" 
                SelectCommand = "select approved_denied_by=case when b.bonus_status = 'Denied' then denied_by when b.bonus_status = 'Approved' then approved_by else null end,
                                            approved_denied_date=case when b.bonus_status = 'Denied' then denied_date when b.bonus_status = 'Approved' then approved_date else null end, b.*,rtrim(p.first_name)+' '+rtrim(p.last_name) Name,rtrim(ps.first_name)+' '+rtrim(ps.last_name) submitter_name 
                                    from bonus_local b, people p , people ps
                                    where ps.network_account = b.created_by and p.employee_id = b.employee_id and b.is_deleted=0 and b.bonus_status in ('Pending Approval','Denied','Approved')
                                    /* and employee_status<>'terminated'  */  
                                    and case b.bonus_status when 'Denied' then datediff(dd,denied_date,getdate()) 
															when 'Approved' then datediff(dd,approved_date,getdate())
															else 0 end < 1
                                    and p.charge_to_location in 
                                    (
	                                    select distinct location_num
	                                    from role_location a, gldm_location b
	                                    where scheme_cd ='PRO' and role_cd <>'spprt'
	                                    and employee_id = (select employee_id from people where network_account = '" + Session["uid"].ToString() + @"')
	                                    and 
	                                    (
	                                    a.location_cd_prefixed = 'div0'+rtrim(b.division_num)
	                                    or
	                                    a.location_cd_prefixed = 'com0'+rtrim(b.company_num)
	                                    or
	                                    a.location_cd_prefixed = 'OPE0'+rtrim(b.operation_num)
	                                    or
	                                    a.location_cd_prefixed = 'BUS0'+rtrim(b.business_unit_num)
	                                    or
	                                    a.location_cd_prefixed = 'TER0'+rtrim(b.territory_num)
	                                    or
	                                    a.location_cd_prefixed = 'MAR0'+rtrim(b.market_num)
	                                    or
	                                    a.location_cd_prefixed = 'ARE0'+rtrim(b.market_num)
	                                    or
	                                    a.location_cd_prefixed = 'Meg0'+rtrim(b.mega_location_num) 
	                                    or
	                                    a.location_cd_prefixed = location_num
                                        )
                                    )
                                    order by rtrim(p.first_name)+' '+rtrim(p.last_name) "
               >
            </asp:SqlDataSource>

Open in new window

0
Comment
Question by:dpicco
5 Comments
 
LVL 9

Expert Comment

by:abhinayp86
ID: 37722658
try this

SelectCommand = '<%# "select approved_denied_by=case when b.bonus_status = 'Denied' then denied_by when b.bonus_status = 'Approved' then approved_by else null end, _
                                            approved_denied_date=case when b.bonus_status = 'Denied' then denied_date when b.bonus_status = 'Approved' then approved_date else null end, b.*,rtrim(p.first_name)+' '+rtrim(p.last_name) Name,rtrim(ps.first_name)+' '+rtrim(ps.last_name) submitter_name 
                                    from bonus_local b, people p , people ps
                                    where ps.network_account = b.created_by and p.employee_id = b.employee_id and b.is_deleted=0 and b.bonus_status in ('Pending Approval','Denied','Approved')
                                    and employee_status<>'terminated'  */  
                                    and case b.bonus_status when 'Denied' then datediff(dd,denied_date,getdate()) 
															when 'Approved' then datediff(dd,approved_date,getdate())
															else 0 end < 1
                                    and p.charge_to_location in 
                                    (
	                                    select distinct location_num
	                                    from role_location a, gldm_location b
	                                    where scheme_cd ='PRO' and role_cd <>'spprt'
	                                    and employee_id = (select employee_id from people where network_account = '" + Session["uid"].ToString() + @"')
	                                    and 
	                                    (
	                                    a.location_cd_prefixed = 'div0'+rtrim(b.division_num)
	                                    or
	                                    a.location_cd_prefixed = 'com0'+rtrim(b.company_num)
	                                    or
	                                    a.location_cd_prefixed = 'OPE0'+rtrim(b.operation_num)
	                                    or
	                                    a.location_cd_prefixed = 'BUS0'+rtrim(b.business_unit_num)
	                                    or
	                                    a.location_cd_prefixed = 'TER0'+rtrim(b.territory_num)
	                                    or
	                                    a.location_cd_prefixed = 'MAR0'+rtrim(b.market_num)
	                                    or
	                                    a.location_cd_prefixed = 'ARE0'+rtrim(b.market_num)
	                                    or
	                                    a.location_cd_prefixed = 'Meg0'+rtrim(b.mega_location_num) 
	                                    or
	                                    a.location_cd_prefixed = location_num
                                        )
                                    )
                                    order by rtrim(p.first_name)+' '+rtrim(p.last_name)"%>' 

Open in new window


its either <%# (asp.net 3.5) or <%$(not sure about 4.0)
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 37722672
The continuation character is an underscore ensure there is a space between the last character on the line and the underscore.
I think that you will possibly need to close each line with a " and use an & as well like this :


"some string " & _
"another string " & _
...
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 200 total points
ID: 37722729
You won't be able to do the concatenation you have within this line:

and employee_id = (select employee_id from people where network_account = '" + Session["uid"].ToString() + @"')

Open in new window


You would need to add a placeholder and add a SessionParameter to the command's SelectParameters collection:

...

                            and employee_id = (select employee_id from people where network_account = @uid)
                            and 
                            (
                            a.location_cd_prefixed = 'div0'+rtrim(b.division_num)
                            or
                            a.location_cd_prefixed = 'com0'+rtrim(b.company_num)
                            or
                            a.location_cd_prefixed = 'OPE0'+rtrim(b.operation_num)
                            or
                            a.location_cd_prefixed = 'BUS0'+rtrim(b.business_unit_num)
                            or
                            a.location_cd_prefixed = 'TER0'+rtrim(b.territory_num)
                            or
                            a.location_cd_prefixed = 'MAR0'+rtrim(b.market_num)
                            or
                            a.location_cd_prefixed = 'ARE0'+rtrim(b.market_num)
                            or
                            a.location_cd_prefixed = 'Meg0'+rtrim(b.mega_location_num) 
                            or
                            a.location_cd_prefixed = location_num
                            )
                        )
                        order by rtrim(p.first_name)+' '+rtrim(p.last_name) "
   >
   <SelectParameters>
       <asp:SessionParameter SessionField="uid" Name="@uid" />
   </SelectParameters>
</asp:SqlDataSource>

Open in new window

0
 
LVL 16

Accepted Solution

by:
Vikram Singh Saini earned 300 total points
ID: 37723199
Hi,

I have a very long sql in my asp.net markup like this. What line continuation character do I use?

There is no line continuation in .aspx or .html (as .aspx page would get converted to html one after compilation or at runtime). But solution exists for prob.(The HTML Document Character Set)

I have changed some of characters (<,> and ") in query to their Decimal Code(&#60;, &#62; and &quot;) respectively. No need to worry for them as they would get converted to their respective characters in html generated.

However I was not able to test your query. Let us know if it helped you or not. Below is modified code(only special characters):

<asp:SqlDataSource ID="sdsBonuses" runat="server" ConnectionString="<%$ ConnectionStrings:AdHocReportingConnectionString %>"
            SelectCommand="select approved_denied_by=case when b.bonus_status = 'Denied' then denied_by when b.bonus_status = 'Approved' then approved_by else null end,
                                            approved_denied_date=case when b.bonus_status = 'Denied' then denied_date when b.bonus_status = 'Approved' then approved_date else null end, b.*,rtrim(p.first_name)+' '+rtrim(p.last_name) Name,rtrim(ps.first_name)+' '+rtrim(ps.last_name) submitter_name 
                                    from bonus_local b, people p , people ps
                                    where ps.network_account = b.created_by and p.employee_id = b.employee_id and b.is_deleted=0 and b.bonus_status in ('Pending Approval','Denied','Approved')
                                    /* and employee_status&#60;&#62;'terminated'  */  
                                    and case b.bonus_status when 'Denied' then datediff(dd,denied_date,getdate()) 
															when 'Approved' then datediff(dd,approved_date,getdate())
															else 0 end &#60; 1
                                    and p.charge_to_location in 
                                    (
	                                    select distinct location_num
	                                    from role_location a, gldm_location b
	                                    where scheme_cd ='PRO' and role_cd &#60;&#62;'spprt'
	                                    and employee_id = (select employee_id from people where network_account = '&quot; + Session[&quot;uid&quot;].ToString() + &quot;')
	                                    and 
	                                    (
	                                    a.location_cd_prefixed = 'div0'+rtrim(b.division_num)
	                                    or
	                                    a.location_cd_prefixed = 'com0'+rtrim(b.company_num)
	                                    or
	                                    a.location_cd_prefixed = 'OPE0'+rtrim(b.operation_num)
	                                    or
	                                    a.location_cd_prefixed = 'BUS0'+rtrim(b.business_unit_num)
	                                    or
	                                    a.location_cd_prefixed = 'TER0'+rtrim(b.territory_num)
	                                    or
	                                    a.location_cd_prefixed = 'MAR0'+rtrim(b.market_num)
	                                    or
	                                    a.location_cd_prefixed = 'ARE0'+rtrim(b.market_num)
	                                    or
	                                    a.location_cd_prefixed = 'Meg0'+rtrim(b.mega_location_num) 
	                                    or
	                                    a.location_cd_prefixed = location_num
                                        )
                                    )
                                    order by rtrim(p.first_name)+' '+rtrim(p.last_name)"></asp:SqlDataSource>

Open in new window

0
 
LVL 3

Author Closing Comment

by:dpicco
ID: 37734313
thank you. That worked.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to get the web content with different encodings 2 29
Server Error 11 47
Connection String 16 43
Pagebreak issue while printing the aspx page 3 16
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now