tag:blogger.com,1999:blog-75913915527789278292024-03-16T16:31:17.247-07:00DOTNET WORLDYour .NET problem's end's hereUnknownnoreply@blogger.comBlogger144125tag:blogger.com,1999:blog-7591391552778927829.post-64018198649388617232014-03-08T00:24:00.000-08:002014-03-08T00:24:39.621-08:00How to use Export Excel in DHTMLX Grid<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">1. In order to use export<span style="mso-spacerun: yes;">
</span>to excel in dhtmlgrid. We <span style="mso-spacerun: yes;"> </span>need
to<span style="mso-spacerun: yes;"> </span>download(http://dhtmlx.com/x/download/regular/grid-excel-net.zip)
and add the following two library reference to the project.</span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Calibri;"><span style="mso-spacerun: yes;"> </span>1.</span><span style="font-family: Consolas; font-size: 9.5pt;"> DHTMLX.Export.Excel<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;"><span style="mso-spacerun: yes;"> </span>2.<span style="mso-spacerun: yes;"> </span>Openxml</span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">2. Need to include “dhtmlxgrid_export.js” script file
reference from the following location “../codebase/ext/” directory to<span style="mso-spacerun: yes;"> </span>your web page.</span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Calibri;">3. Use “</span><span style="font-family: Consolas; font-size: 9.5pt;">toExcel” function with your
dhtmlgrid. Which will expects serverside controller action url. In this action
we need to define logic to download dhtmlgrid to excel.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">Sample Code:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">===========<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">Client Side Code:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">================== <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>grid.toExcel(<span style="color: maroon;"><a href="mailto:'@Url.Content(%22~/ExcelTest/ExportGridToExcel%22)'">'<span style="background: yellow; mso-highlight: yellow;">@</span></a></span><a href="https://www.blogger.com/null">Url.Content(<span style="color: #a31515;">"~/ExcelTest/ExportGridToExcel"</span>)</a><span style="color: maroon;"><a href="https://www.blogger.com/null">'</a></span>);<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">Server Side Code:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">================<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">ExcelTest Contoller:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">==================================<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">Need to include “DHTMLX.Export.Excel” namespace to
the controller.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> DHTMLX.Export.Excel;<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">public</span> <span style="color: #2b91af;">ActionResult</span>
ExportGridToExcel()<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> generator = <span style="color: blue;">new</span> <span style="color: #2b91af;">ExcelWriter</span>();<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> xml = <span style="color: blue;">this</span>.Request.Form[<span style="color: #a31515;">"grid_xml"</span>];<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>xml = <span style="color: blue;">this</span>.Server.UrlDecode(xml);<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> stream = generator.Generate(xml);<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">return</span> File(stream.ToArray(), generator.ContentType, <span style="color: #a31515;">"grid.xlsx"</span>);<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">In the “grid_xml”. “grid_” will be ghtmlgrid name.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<o:p><span style="font-family: Calibri;"> </span></o:p></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="mso-spacerun: yes;"><span style="font-family: Calibri;"> </span></span></div>
</div>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-7591391552778927829.post-56272949854432633932013-09-27T03:50:00.000-07:002013-09-27T03:51:24.246-07:00User Defined Functions in SQL Server and How to pass table column value as the input parmeter of UDF<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<b style="margin: 0px; padding: 0px;">UDF</b><span class="Apple-converted-space"> </span>or<span class="Apple-converted-space"> </span><b style="margin: 0px; padding: 0px;">User Defined Functions</b><span class="Apple-converted-space"> </span>are a set or batch of code where one can apply any SQL logic and return a single scalar value or a record set.</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
According to MS BOL UDFs are the<span class="Apple-converted-space"> </span><b style="margin: 0px; padding: 0px;">subroutines<span class="Apple-converted-space"> </span></b>made up of one or more Transact-SQL statements that can be used to encapsulate code for reuse.<span class="Apple-converted-space"> </span><b style="margin: 0px; padding: 0px;"><i style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; text-decoration: underline;">These reusable subroutines can be used as</span></i>:</b><br />
- In TSQL SELECT statements at column level.<br />
- To create parametrized view or improve the functionality of in indexed view.<br />
- To define a column and CHECK constraints while creating a table.<br />
- To replace a stored procedures and views.<br />
- Join complex logic with a table where a stored procedure fails.<br />
- Faster execution like Stored procedures, reduce compliation cost by caching the execution query plans.</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<b style="margin: 0px; padding: 0px;"><i style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; text-decoration: underline;">Apart from the benefits UDF’s has certain limitations</span></i>:</b><br />
- Can not modify any database objects, limited to update table variables only.<br />
- Can not contain the new OUTPUT clause.<br />
- Can only call extended stored procedures, no other procedures.<br />
- Can not define TRY-CATCH block.<br />
- Some built-in functions are not allowed here, like:GETDATE(), because GETDATE is non-deterministic as its value changes every time it is called. On the other hand DATEADD() is allowed as it is deterministic, because it will return same result when called with same argument values.</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
A UDF can take 0 or upto 1024 parameters and returns either a scalar value or a table record set depending on its type.<br />
<b style="margin: 0px; padding: 0px;"><i style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; text-decoration: underline;">SQL Server supports mainly 3 types of UDFs</span>:</i></b><br />
1. Scalar function<br />
2. Inline table-valued function<br />
3. Multistatement table-valued function</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<b style="margin: 0px; padding: 0px;">1.<span class="Apple-converted-space"> </span><span style="margin: 0px; padding: 0px; text-decoration: underline;">Scalar function</span>:</b><span class="Apple-converted-space"> </span>Returns a single value of any datatype except text, ntext, image, cursor & timestamp.</div>
<pre class="brush: sql; title: ; notranslate" style="-webkit-text-stroke-width: 0px; background-color: #f4f5f7; background-image: url(http://s2.wp.com/wp-content/themes/pub/inove/img/blockquote.gif); background-position: 3px 3px; background-repeat: no-repeat no-repeat; border: 1px dashed rgb(204, 204, 204); color: #555555; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 5px 0px; orphans: auto; padding: 8px 12px 8px 36px; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px;" title="">-- Example:
--// Create Scalar UDF [dbo].[ufn_GetContactOrders]
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[ufn_GetContactOrders](@ContactID int)
RETURNS varchar(500)
AS
BEGIN
DECLARE @Orders varchar(500)
SELECT @Orders = COALESCE(@Orders + ', ', '') + CAST(SalesOrderID as varchar(10))
FROM Sales.SalesOrderHeader
WHERE ContactID = @ContactID
RETURN (@Orders)
END
--// Usage:
-- Used at COLUMN level with SELECT
SELECT ContactID, dbo.ufn_GetContactOrders(ContactID) FROM Person.Contact
WHERE ContactID between 100 and 105 -- Output below
-- Used while defining a computed column while creating a table.
CREATE TABLE tempCustOrders (CustID int, Orders as (dbo.ufn_GetContactOrders(CustID)))
INSERT INTO tempCustOrders (CustID)
SELECT ContactID FROM Person.Contact
WHERE ContactID between 100 and 105
SELECT * FROM tempCustOrders -- Output below
DROP TABLE tempCustOrders
</pre>
<pre style="-webkit-text-stroke-width: 0px; background-color: #f4f5f7; background-image: url(http://s2.wp.com/wp-content/themes/pub/inove/img/blockquote.gif); background-position: 3px 3px; background-repeat: no-repeat no-repeat; border: 1px dashed rgb(204, 204, 204); color: #555555; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 5px 0px; orphans: auto; padding: 8px 12px 8px 36px; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px;">Output of both the selects above:
<b style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; text-decoration: underline;">ContactID OrdersCSV</span></b>
100 51702, 57021, 63139, 69398
101 47431, 48369, 49528, 50744, 53589, 59017, 65279, 71899
102 43874, 44519, 46989, 48013, 49130, 50274, 51807, 57113, 63162, 69495
103 43691, 44315, 45072, 45811, 46663, 47715, 48787, 49887, 51144, 55310, 61247, 67318
104 43866, 44511, 45295, 46052, 46973, 47998, 49112, 50215, 51723, 57109, 63158, 69420
105 NULL</pre>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<i style="margin: 0px; padding: 0px;"><b style="margin: 0px; padding: 0px;">Note:</b><span class="Apple-converted-space"> </span>If this was a temp(#) table then the function also needs to be created in tempdb, cause the temp table belongs to tempdb. The tables in function should also have the database name prefixed, i.e.</i><span class="Apple-converted-space"> </span><b style="margin: 0px; padding: 0px;">[AdventureWorks].[Sales].[SalesOrderHeader]</b></div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<b style="margin: 0px; padding: 0px;">2.<span class="Apple-converted-space"> </span><span style="margin: 0px; padding: 0px; text-decoration: underline;">Inline table-valued function</span>:</b><span class="Apple-converted-space"> </span>Returns a table i.e. a record-set. The function body contains just a single TSQL statement, which results to a record-set and is returned from here.</div>
<pre class="brush: sql; title: ; notranslate" style="-webkit-text-stroke-width: 0px; background-color: #f4f5f7; background-image: url(http://s2.wp.com/wp-content/themes/pub/inove/img/blockquote.gif); background-position: 3px 3px; background-repeat: no-repeat no-repeat; border: 1px dashed rgb(204, 204, 204); color: #555555; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 5px 0px; orphans: auto; padding: 8px 12px 8px 36px; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px;" title="">-- Example:
--// Create Inline table-valued UDF [dbo].[ufn_itv_GetContactSales]
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[ufn_itv_GetContactSales](@ContactID int)
RETURNS TABLE
AS
RETURN (
SELECT h.[ContactID], h.[SalesOrderID], p.[ProductID], p.[Name], h.[OrderDate], h.[DueDate],
h.[ShipDate], h.[TotalDue], h.[Status], h.[SalesPersonID]
FROM Sales.SalesOrderHeader AS h
JOIN Sales.SalesOrderDetail AS d ON d.SalesOrderID = h.SalesOrderID
JOIN Production.Product AS p ON p.ProductID = d.ProductID
WHERE ContactID = @ContactID )
--// Usage:
SELECT * FROM ufn_itv_GetContactSales(100)
</pre>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<b style="margin: 0px; padding: 0px;">3.<span class="Apple-converted-space"> </span><span style="margin: 0px; padding: 0px; text-decoration: underline;">Multistatement table-valued function</span>:</b><span class="Apple-converted-space"> </span>Also returns a table (record-set) but can contain multiple TSQL statements or scripts and is defined in BEGIN END block. The final set of rows are then returned from here.</div>
<pre class="brush: sql; title: ; notranslate" style="-webkit-text-stroke-width: 0px; background-color: #f4f5f7; background-image: url(http://s2.wp.com/wp-content/themes/pub/inove/img/blockquote.gif); background-position: 3px 3px; background-repeat: no-repeat no-repeat; border: 1px dashed rgb(204, 204, 204); color: #555555; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 5px 0px; orphans: auto; padding: 8px 12px 8px 36px; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px;" title="">-- Example:
--// Create Multistatement table-valued UDF [dbo].[ufn_mtv_GetContactSales]
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[ufn_mtv_GetContactSales](@ContactID int)
RETURNS @retSalesInfo TABLE (
[ContactID] INT NOT NULL,
[SalesOrderID] INT NULL,
[ProductID] INT NULL,
[Name] NVARCHAR(50) NULL,
[OrderDate] DATETIME NULL,
[DueDate] DATETIME NULL,
[ShipDate] DATETIME NULL,
[TotalDue] MONEY NULL,
[Status] TINYINT NULL,
[SalesPersonID] INT NULL)
AS
BEGIN
IF @ContactID IS NOT NULL
BEGIN
INSERT @retSalesInfo
SELECT h.[ContactID], h.[SalesOrderID], p.[ProductID], p.[Name], h.[OrderDate], h.[DueDate],
h.[ShipDate], h.[TotalDue], h.[Status], h.[SalesPersonID]
FROM Sales.SalesOrderHeader AS h
JOIN Sales.SalesOrderDetail AS d ON d.SalesOrderID = h.SalesOrderID
JOIN Production.Product AS p ON p.ProductID = d.ProductID
WHERE ContactID = @ContactID
END
-- Return the recordsets
RETURN
END
--// Usage:
SELECT * FROM ufn_mtv_GetContactSales(100)
</pre>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
– Output:</div>
<div class="wp-caption alignnone" id="attachment_241" style="-webkit-text-stroke-width: 0px; background-color: #f7f7f7; background-position: initial initial; background-repeat: initial initial; border: 1px solid rgb(204, 204, 204); color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 5px; max-width: 99.5%; orphans: auto; padding: 5px 0px; text-align: center; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 310px; word-spacing: 0px;">
<a href="http://sqlwithmanoj.files.wordpress.com/2010/12/udf.jpg" style="color: #2970a6; margin: 0px; padding: 0px; text-decoration: none;" target="_blank"><img alt="TVF & MVF output" class="size-medium wp-image-241 " height="73" src="http://sqlwithmanoj.files.wordpress.com/2010/12/udf.jpg?w=300&h=73" style="border: 0px; height: auto; margin: 0px 5px; max-width: 98%; padding: 0px;" title="TVF & MVF output" width="300" /></a><br />
<div class="wp-caption-text" style="margin: 0px; padding: 0px 5px !important; text-align: center;">
TVF & MVF output</div>
</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<i style="margin: 0px; padding: 0px;"><b style="margin: 0px; padding: 0px;"><br /></b></i></div>
<h2 style="-webkit-text-stroke-width: 0px; background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; clear: both; color: #555555; display: block; font-family: Verdana, 'BitStream vera Sans'; font-size: 16px; font-style: normal; font-variant: normal; font-weight: bold; letter-spacing: normal; line-height: normal; margin: 10px 0px 0px; orphans: auto; padding: 0px 5px 3px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
CROSS APPLY vs OUTER APPLY</h2>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
UDFs can be used in queries at column level, table levels and on column definition while creating tables.<br />
They can also be joined with other tables, but not by simple joins. They have special joins called<span class="Apple-converted-space"> </span><b style="margin: 0px; padding: 0px;">APPLY<span class="Apple-converted-space"> </span></b>operator.</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
According to MS BOL an<span class="Apple-converted-space"> </span><b style="margin: 0px; padding: 0px;">APPLY<span class="Apple-converted-space"> </span></b>operator allows you to invoke a table-valued function for each row returned by an outer table expression of a query. The table-valued function acts as the right input and the outer table expression acts as the left input. The right input is evaluated for each row from the left input and the rows produced are combined for the final output. The list of columns produced by the APPLY operator is the set of columns in the left input followed by the list of columns returned by the right input.</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<i style="margin: 0px; padding: 0px;"><b style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; text-decoration: underline;">There are 2 forms of APPLY</span>:</b></i><br />
<b style="margin: 0px; padding: 0px;">- CROSS APPLY</b><span class="Apple-converted-space"> </span>acts as INNER JOIN, returns only rows from the outer table that produce a result set from the table-valued function.<br />
<b style="margin: 0px; padding: 0px;">- OUTER APPLY</b><span class="Apple-converted-space"> </span>acts as OUTER JOIN, returns both rows that produce a result set, and rows that do not, with NULL values in the columns produced by the table-valued function.</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
Lets take 2 tables:<span class="Apple-converted-space"> </span><b style="margin: 0px; padding: 0px;">Person.Contact</b><span class="Apple-converted-space"> </span>&<span class="Apple-converted-space"> </span><b style="margin: 0px; padding: 0px;">Sales.SalesOrderHeader</b></div>
<pre class="brush: sql; title: ; notranslate" style="-webkit-text-stroke-width: 0px; background-color: #f4f5f7; background-image: url(http://s2.wp.com/wp-content/themes/pub/inove/img/blockquote.gif); background-position: 3px 3px; background-repeat: no-repeat no-repeat; border: 1px dashed rgb(204, 204, 204); color: #555555; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 5px 0px; orphans: auto; padding: 8px 12px 8px 36px; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px;" title="">SELECT * FROM Person.Contact WHERE ContactID = 100
SELECT * FROM Sales.SalesOrderHeader WHERE ContactID = 100
</pre>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
You have a UDF that returns Sales Order Details of a Particular Contact. Now you want to use that UDF to know what all Contacts have Ordered what with other details. Lets see:</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<i style="margin: 0px; padding: 0px;"><b style="margin: 0px; padding: 0px;">First creating a UDF to test with JOINS & APPLY:</b></i></div>
<pre class="brush: sql; title: ; notranslate" style="-webkit-text-stroke-width: 0px; background-color: #f4f5f7; background-image: url(http://s2.wp.com/wp-content/themes/pub/inove/img/blockquote.gif); background-position: 3px 3px; background-repeat: no-repeat no-repeat; border: 1px dashed rgb(204, 204, 204); color: #555555; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 5px 0px; orphans: auto; padding: 8px 12px 8px 36px; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px;" title="">--// Create Multiline UserDefinedFunction [dbo].[ufn_mtv_GetContactSales]
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[ufn_mtv_GetContactSales](@ContactID int)
RETURNS @retSalesInfo TABLE (
[ContactID] INT NOT NULL,
[SalesOrderID] INT NULL,
[ProductID] INT NULL,
[Name] NVARCHAR(50) NULL,
[OrderDate] DATETIME NULL,
[DueDate] DATETIME NULL,
[ShipDate] DATETIME NULL,
[TotalDue] MONEY NULL,
[Status] TINYINT NULL,
[SalesPersonID] INT NULL)
AS
BEGIN
IF @ContactID IS NOT NULL
BEGIN
INSERT @retSalesInfo
SELECT h.[ContactID], h.[SalesOrderID], p.[ProductID], p.[Name], h.[OrderDate], h.[DueDate],
h.[ShipDate], h.[TotalDue], h.[Status], h.[SalesPersonID]
FROM Sales.SalesOrderHeader AS h
JOIN Sales.SalesOrderDetail AS d ON d.SalesOrderID = h.SalesOrderID
JOIN Production.Product AS p ON p.ProductID = d.ProductID
WHERE ContactID = @ContactID
END
-- Return the recordsets
RETURN
END
--// Test the UDF
SELECT * FROM dbo.ufn_mtv_GetContactSales(100)
</pre>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<i style="margin: 0px; padding: 0px;"><b style="margin: 0px; padding: 0px;">Trying to JOIN UDF with a table, problem is you need to apply a parameter and it can’t be a column, but a value:</b></i></div>
<pre class="brush: sql; title: ; notranslate" style="-webkit-text-stroke-width: 0px; background-color: #f4f5f7; background-image: url(http://s2.wp.com/wp-content/themes/pub/inove/img/blockquote.gif); background-position: 3px 3px; background-repeat: no-repeat no-repeat; border: 1px dashed rgb(204, 204, 204); color: #555555; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 5px 0px; orphans: auto; padding: 8px 12px 8px 36px; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px;" title="">--// UDF with JOIN, try it out!!!
SELECT *
FROM Person.Contact c
JOIN dbo.ufn_mtv_GetContactSales(100) f -- You will have to pass the ContactID parameter, so no use of joining.
ON f.ContactID = c.ContactID
</pre>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<i style="margin: 0px; padding: 0px;"><b style="margin: 0px; padding: 0px;">Testing with CROSS APPLY:</b></i></div>
<pre class="brush: sql; title: ; notranslate" style="-webkit-text-stroke-width: 0px; background-color: #f4f5f7; background-image: url(http://s2.wp.com/wp-content/themes/pub/inove/img/blockquote.gif); background-position: 3px 3px; background-repeat: no-repeat no-repeat; border: 1px dashed rgb(204, 204, 204); color: #555555; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 5px 0px; orphans: auto; padding: 8px 12px 8px 36px; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px;" title="">--// CROSS APPLY -- 279 records (All matched records, 1 missing out of 280)
SELECT c.[ContactID], c.[FirstName], c.[LastName], c.[EmailAddress], c.[Phone], s.*
FROM Person.Contact AS c
CROSS APPLY ufn_mtv_GetContactSales(c.ContactID) AS s
WHERE c.ContactID between 100 and 105
-- Same equivalent query without cross apply, using JOINs -- 279 records
SELECT c.[ContactID], c.[FirstName], c.[LastName], c.[EmailAddress], c.[Phone],
h.[ContactID], h.[SalesOrderID], p.[ProductID], p.[Name], h.[OrderDate], h.[DueDate],
h.[ShipDate], h.[TotalDue], h.[Status], h.[SalesPersonID]
FROM Person.Contact AS c
JOIN Sales.SalesOrderHeader AS h ON c.ContactID = h.ContactID
JOIN Sales.SalesOrderDetail AS d ON d.SalesOrderID = h.SalesOrderID
JOIN Production.Product AS p ON p.ProductID = d.ProductID
WHERE c.ContactID between 100 and 105
</pre>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<b style="margin: 0px; padding: 0px;"><i style="margin: 0px; padding: 0px;">Testing with OUTER APPLY:</i></b></div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<br /></div>
<pre class="brush: sql; title: ; notranslate" style="-webkit-text-stroke-width: 0px; background-color: #f4f5f7; background-image: url(http://s2.wp.com/wp-content/themes/pub/inove/img/blockquote.gif); background-position: 3px 3px; background-repeat: no-repeat no-repeat; border: 1px dashed rgb(204, 204, 204); color: #555555; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 5px 0px; orphans: auto; padding: 8px 12px 8px 36px; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px;" title="">--// OUTER APPLY -- 280 records (All 280 records with 1 not matched)
SELECT c.[ContactID], c.[FirstName], c.[LastName], c.[EmailAddress], c.[Phone], s.*
FROM Person.Contact AS c
OUTER APPLY ufn_mtv_GetContactSales(c.ContactID) AS s
WHERE c.ContactID between 100 and 105
-- Same equivalent query without OUTER APPLY, using LEFT JOINs -- 280 records
SELECT c.[ContactID], c.[FirstName], c.[LastName], c.[EmailAddress], c.[Phone],
h.[ContactID], h.[SalesOrderID], p.[ProductID], p.[Name], h.[OrderDate], h.[DueDate],
h.[ShipDate], h.[TotalDue], h.[Status], h.[SalesPersonID]
FROM Person.Contact AS c
LEFT JOIN Sales.SalesOrderHeader AS h ON c.ContactID = h.ContactID
LEFT JOIN Sales.SalesOrderDetail AS d ON d.SalesOrderID = h.SalesOrderID
LEFT JOIN Production.Product AS p ON p.ProductID = d.ProductID
WHERE c.ContactID between 100 and 105
</pre>
<div style="-webkit-text-stroke-width: 0px; background-color: white; color: #555555; font-family: Verdana, 'BitStream vera Sans', Helvetica, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<b style="margin: 0px; padding: 0px;"><i style="margin: 0px; padding: 0px;"><span style="margin: 0px; padding: 0px; text-decoration: underline;">MSDN links</span>:</i><br style="margin: 0px; padding: 0px;" /><i style="margin: 0px; padding: 0px;"><a href="http://technet.microsoft.com/en-us/library/ms175156.aspx" style="color: #2970a6; margin: 0px; padding: 0px; text-decoration: none;" target="_blank">http://technet.microsoft.com/en-us/library/ms175156.aspx</a></i></b></div>
<h2 style="-webkit-text-stroke-width: 0px; background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; clear: both; color: #555555; display: block; font-family: Verdana, 'BitStream vera Sans'; font-size: 16px; font-style: normal; font-variant: normal; font-weight: bold; letter-spacing: normal; line-height: normal; margin: 10px 0px 0px; orphans: auto; padding: 0px 5px 3px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
</h2>
<h2 style="-webkit-text-stroke-width: 0px; background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; clear: both; color: #555555; display: block; font-family: Verdana, 'BitStream vera Sans'; font-size: 16px; font-style: normal; font-variant: normal; font-weight: bold; letter-spacing: normal; line-height: normal; margin: 10px 0px 0px; orphans: auto; padding: 0px 5px 3px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
More Details about CROSS APPLY and OUTER APPLY</h2>
<div style="-webkit-text-stroke-width: 0px; background-color: white; background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #333333; font-family: 'Segoe UI', 'PT Sans', sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; margin: 0px 0px 17px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
My first introduction to the APPLY operator was using the DMVs. For quite a while after first being introduced, I didn’t understand it or see a use for it. While it is undeniable that it is has some required uses when dealing with table valued functions, it’s other uses evaded me for a while. Luckily, I started seeing some code that used it outside of table valued functions. It finally struck me that it could be used as a replacement for correlated sub queries and derived tables. That’s what we’ll discuss today.</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #333333; font-family: 'Segoe UI', 'PT Sans', sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; margin: 0px 0px 17px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
I never liked correlated subqueries because it always seemed like adding full blown queries in the select list was confusing and improper.</div>
<div class="codecolorer-container sql default block style01" style="-webkit-text-stroke-width: 0px; background-color: #fcfbe3; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(251, 237, 188); color: #393939; font-family: Inconsolata, 'Courier New'; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px auto 20px; orphans: auto; overflow: auto; padding: 13px 18px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 712.5px; word-spacing: 0px;">
<div class="sql codecolorer" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 15px; margin: 0px; padding: 0px;">
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">SELECT</span><span class="Apple-converted-space"> </span><br />
SalesOrderID <span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span>soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<br />
<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">,</span>OrderDate <span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span>soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>OrderDate<br />
<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">,</span>MaxUnitPrice <span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span><span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">(</span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">SELECT</span><span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">MAX</span><span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">(</span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>UnitPrice<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">)</span><span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">FROM</span><span class="Apple-converted-space"> </span>Sales<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderDetail sod<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">WHERE</span><span class="Apple-converted-space"> </span>soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">)</span><br />
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">FROM</span><span class="Apple-converted-space"> </span>AdventureWorks<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>Sales<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderHeader<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">AS</span><span class="Apple-converted-space"> </span>soh</div>
</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #333333; font-family: 'Segoe UI', 'PT Sans', sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; margin: 0px 0px 17px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
It always seemed to me that these operations should go below the FROM clause. So to get around this, I would typically create a derived table. Which didn’t completely feel right either, but it was still just a bit cleaner:</div>
<div class="codecolorer-container sql default block style01" style="-webkit-text-stroke-width: 0px; background-color: #fcfbe3; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(251, 237, 188); color: #393939; font-family: Inconsolata, 'Courier New'; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px auto 20px; orphans: auto; overflow: auto; padding: 13px 18px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 712.5px; word-spacing: 0px;">
<div class="sql codecolorer" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 15px; margin: 0px; padding: 0px;">
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">SELECT</span><span class="Apple-converted-space"> </span><br />
soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<br />
<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">,</span>soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>OrderDate<br />
<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">,</span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>max_unit_price<br />
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">FROM</span><span class="Apple-converted-space"> </span>AdventureWorks<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>Sales<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderHeader<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">AS</span><span class="Apple-converted-space"> </span>soh<br />
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">JOIN</span><br />
<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">(</span><br />
<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">SELECT</span><span class="Apple-converted-space"> </span><br />
max_unit_price<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">MAX</span><span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">(</span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>UnitPrice<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">)</span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">,</span><br />
SalesOrderID<br />
<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">FROM</span><span class="Apple-converted-space"> </span>Sales<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderDetail<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">AS</span><span class="Apple-converted-space"> </span>sod<br />
<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">GROUP</span><span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">BY</span><span class="Apple-converted-space"> </span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<br />
<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">)</span><span class="Apple-converted-space"> </span>sod<br />
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">ON</span><span class="Apple-converted-space"> </span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span>soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID</div>
</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #333333; font-family: 'Segoe UI', 'PT Sans', sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; margin: 0px 0px 17px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
What made this ugly was the need to use the GROUP BY clause because we could not correlate. Also, even though SQL almost always generates the same execution plan as a correlated sub query, there were times when the logic inside the derived table got so complex, that it would not limit the result set of the derived table by inferring the correlation first. This made this kind of query sometimes impractical.</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #333333; font-family: 'Segoe UI', 'PT Sans', sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; margin: 0px 0px 17px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
Luckily, this is where the CROSS APPLY steps in so nicely. It gives us the best of both worlds by allowing us to correlate AND not have the query embedded in the select list:</div>
<div class="codecolorer-container sql default block style01" style="-webkit-text-stroke-width: 0px; background-color: #fcfbe3; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(251, 237, 188); color: #393939; font-family: Inconsolata, 'Courier New'; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px auto 20px; orphans: auto; overflow: auto; padding: 13px 18px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 712.5px; word-spacing: 0px;">
<div class="sql codecolorer" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 15px; margin: 0px; padding: 0px;">
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">SELECT</span><span class="Apple-converted-space"> </span><br />
soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<br />
<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">,</span>soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>OrderDate<br />
<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">,</span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>max_unit_price<br />
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">FROM</span><span class="Apple-converted-space"> </span>AdventureWorks<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>Sales<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderHeader<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">AS</span><span class="Apple-converted-space"> </span>soh<br />
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">CROSS</span><span class="Apple-converted-space"> </span>APPLY<br />
<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">(</span><br />
<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">SELECT</span><span class="Apple-converted-space"> </span><br />
max_unit_price<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">MAX</span><span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">(</span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>UnitPrice<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">)</span><br />
<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">FROM</span><span class="Apple-converted-space"> </span>Sales<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderDetail<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">AS</span><span class="Apple-converted-space"> </span>sod<br />
<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">WHERE</span><span class="Apple-converted-space"> </span>soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<br />
<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">)</span><span class="Apple-converted-space"> </span>sod</div>
</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #333333; font-family: 'Segoe UI', 'PT Sans', sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; margin: 0px 0px 17px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
The other advantage this has over the correlated sub query is when we want to add more columns in our SELECT list, we do not have to completely repeat the entire query. We still have it in one place, making it somewhat modular. So instead of this:</div>
<div class="codecolorer-container sql default block style01" style="-webkit-text-stroke-width: 0px; background-color: #fcfbe3; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(251, 237, 188); color: #393939; font-family: Inconsolata, 'Courier New'; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px auto 20px; orphans: auto; overflow: auto; padding: 13px 18px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 712.5px; word-spacing: 0px;">
<div class="sql codecolorer" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 15px; margin: 0px; padding: 0px;">
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">SELECT</span><span class="Apple-converted-space"> </span><br />
SalesOrderID <span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span>soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<br />
<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">,</span>OrderDate <span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span>soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>OrderDate<br />
<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">,</span>MaxUnitPrice <span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span><span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">(</span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">SELECT</span><span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">MAX</span><span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">(</span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>UnitPrice<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">)</span><span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">FROM</span><span class="Apple-converted-space"> </span>Sales<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderDetail sod<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">WHERE</span><span class="Apple-converted-space"> </span>soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">)</span><span class="Apple-converted-space"> </span><span class="co1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #406040; font-size: 15px; margin: 0px; padding: 0px;">-- 1</span><br />
<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">,</span>SumLineTotal <span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span><span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">(</span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">SELECT</span><span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">SUM</span><span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">(</span>LineTotal<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">)</span><span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">FROM</span><span class="Apple-converted-space"> </span>Sales<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderDetail sod<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">WHERE</span><span class="Apple-converted-space"> </span>soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">)</span><span class="Apple-converted-space"> </span><span class="co1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #406040; font-size: 15px; margin: 0px; padding: 0px;">-- 2</span><br />
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">FROM</span><span class="Apple-converted-space"> </span>AdventureWorks<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>Sales<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderHeader<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">AS</span><span class="Apple-converted-space"> </span>soh</div>
</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #333333; font-family: 'Segoe UI', 'PT Sans', sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; margin: 0px 0px 17px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
We have this:</div>
<div class="codecolorer-container sql default block style01" style="-webkit-text-stroke-width: 0px; background-color: #fcfbe3; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(251, 237, 188); color: #393939; font-family: Inconsolata, 'Courier New'; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px auto 20px; orphans: auto; overflow: auto; padding: 13px 18px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 712.5px; word-spacing: 0px;">
<div class="sql codecolorer" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 15px; margin: 0px; padding: 0px;">
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">SELECT</span><span class="Apple-converted-space"> </span><br />
soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<br />
<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">,</span>soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>OrderDate<br />
<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">,</span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>max_unit_price<br />
<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">,</span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>sum_line_total<br />
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">FROM</span><span class="Apple-converted-space"> </span>AdventureWorks<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>Sales<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderHeader<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">AS</span><span class="Apple-converted-space"> </span>soh<br />
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">CROSS</span><span class="Apple-converted-space"> </span>APPLY<br />
<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">(</span><br />
<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">SELECT</span><span class="Apple-converted-space"> </span><br />
max_unit_price<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">MAX</span><span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">(</span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>UnitPrice<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">)</span><br />
<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">,</span>sum_line_total<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">SUM</span><span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">(</span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>LineTotal<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">)</span><br />
<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">FROM</span><span class="Apple-converted-space"> </span>Sales<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderDetail<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">AS</span><span class="Apple-converted-space"> </span>sod<br />
<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">WHERE</span><span class="Apple-converted-space"> </span>soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<br />
<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">)</span><span class="Apple-converted-space"> </span>sod</div>
</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #333333; font-family: 'Segoe UI', 'PT Sans', sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; margin: 0px 0px 17px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
As for the execution plans, in my experience CROSS APPLY has always won. Not always by a lot, but it still wins.</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #333333; font-family: 'Segoe UI', 'PT Sans', sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; margin: 0px 0px 17px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
So what is OUTER APPLY? It’s equivalent to a left join on the derived table.</div>
<div class="codecolorer-container sql default block style01" style="-webkit-text-stroke-width: 0px; background-color: #fcfbe3; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(251, 237, 188); color: #393939; font-family: Inconsolata, 'Courier New'; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px auto 20px; orphans: auto; overflow: auto; padding: 13px 18px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 712.5px; word-spacing: 0px;">
<div class="sql codecolorer" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 15px; margin: 0px; padding: 0px;">
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">SELECT</span><span class="Apple-converted-space"> </span><br />
soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<br />
<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">,</span>soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>OrderDate<br />
<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">,</span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>max_unit_price<br />
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">FROM</span><span class="Apple-converted-space"> </span>AdventureWorks<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>Sales<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderHeader<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">AS</span><span class="Apple-converted-space"> </span>soh<br />
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">LEFT</span><span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">JOIN</span><br />
<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">(</span><br />
<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">SELECT</span><span class="Apple-converted-space"> </span><br />
max_unit_price<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">MAX</span><span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">(</span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>UnitPrice<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">)</span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">,</span><br />
SalesOrderID<br />
<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">FROM</span><span class="Apple-converted-space"> </span>Sales<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderDetail<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">AS</span><span class="Apple-converted-space"> </span>sod<br />
<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">GROUP</span><span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">BY</span><span class="Apple-converted-space"> </span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<br />
<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">)</span><span class="Apple-converted-space"> </span>sod<br />
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">ON</span><span class="Apple-converted-space"> </span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span>soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID</div>
</div>
<div class="codecolorer-container sql default block style01" style="-webkit-text-stroke-width: 0px; background-color: #fcfbe3; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(251, 237, 188); color: #393939; font-family: Inconsolata, 'Courier New'; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px auto 20px; orphans: auto; overflow: auto; padding: 13px 18px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; width: 712.5px; word-spacing: 0px;">
<div class="sql codecolorer" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 15px; margin: 0px; padding: 0px;">
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">SELECT</span><span class="Apple-converted-space"> </span><br />
soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<br />
<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">,</span>soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>OrderDate<br />
<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">,</span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>max_unit_price<br />
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">FROM</span><span class="Apple-converted-space"> </span>AdventureWorks<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>Sales<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderHeader<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">AS</span><span class="Apple-converted-space"> </span>soh<br />
<span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">OUTER</span><span class="Apple-converted-space"> </span>APPLY<br />
<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">(</span><br />
<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">SELECT</span><span class="Apple-converted-space"> </span><br />
max_unit_price<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">MAX</span><span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">(</span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>UnitPrice<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">)</span><br />
<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">FROM</span><span class="Apple-converted-space"> </span>Sales<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderDetail<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">AS</span><span class="Apple-converted-space"> </span>sod<br />
<span class="Apple-converted-space"> </span><span class="kw1" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2060a0; font-size: 15px; margin: 0px; padding: 0px;">WHERE</span><span class="Apple-converted-space"> </span>soh<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<span class="Apple-converted-space"> </span><span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">=</span><span class="Apple-converted-space"> </span>sod<span class="sy0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">.</span>SalesOrderID<br />
<span class="br0" style="background-image: none; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 15px; margin: 0px; padding: 0px;">)</span><span class="Apple-converted-space"> </span>sod</div>
</div>
<h2 style="-webkit-text-stroke-width: 0px; background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; clear: both; color: #555555; display: block; font-family: Verdana, 'BitStream vera Sans'; font-size: 16px; font-style: normal; font-variant: normal; font-weight: bold; letter-spacing: normal; line-height: normal; margin: 10px 0px 0px; orphans: auto; padding: 0px 5px 3px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
</h2>
<h2 style="-webkit-text-stroke-width: 0px; background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; clear: both; color: #555555; display: block; font-family: Verdana, 'BitStream vera Sans'; font-size: 16px; font-style: normal; font-variant: normal; font-weight: bold; letter-spacing: normal; line-height: normal; margin: 10px 0px 0px; orphans: auto; padding: 0px 5px 3px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
Source: <a href="http://sqlwithmanoj.wordpress.com/2010/12/11/cross-apply-outer-apply/" target="_blank">sqlwithmanoj</a> </h2>
<h2 style="-webkit-text-stroke-width: 0px; background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; clear: both; color: #555555; display: block; font-family: Verdana, 'BitStream vera Sans'; font-size: 16px; font-style: normal; font-variant: normal; font-weight: bold; letter-spacing: normal; line-height: normal; margin: 10px 0px 0px; orphans: auto; padding: 0px 5px 3px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
Source: <a href="http://sqlserverplanet.com/sql-2005/cross-apply-explained" target="_blank">sqlserverplanet.</a> </h2>
<h2 style="-webkit-text-stroke-width: 0px; background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; clear: both; color: #555555; display: block; font-family: Verdana, 'BitStream vera Sans'; font-size: 16px; font-style: normal; font-variant: normal; font-weight: bold; letter-spacing: normal; line-height: normal; margin: 10px 0px 0px; orphans: auto; padding: 0px 5px 3px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
</h2>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7591391552778927829.post-71558199901331616742013-09-21T10:19:00.003-07:002013-09-21T11:02:03.449-07:00How to create Tabs using CSS3 and HTML5 without using Javascript/Jquery<div dir="ltr" style="text-align: left;" trbidi="on">
Today i have learned how to create Tabs without using javascript/jquery with the help of <a href="http://csscience.com/css3-tabs" target="_blank">csscience </a> and <a href="http://css-tricks.com/" target="_blank">css-tricks</a><br />
<a href="http://2.bp.blogspot.com/-zS-i4keH4Rk/Uj3Nhfm8gtI/AAAAAAAAAH4/dwq3zmjx5bA/s1600/tabsimage.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="153" src="http://2.bp.blogspot.com/-zS-i4keH4Rk/Uj3Nhfm8gtI/AAAAAAAAAH4/dwq3zmjx5bA/s640/tabsimage.PNG" width="640" /></a><br />
Download complete example and explanation <a href="https://docs.google.com/uc?id=0BzPmmlHznOWgZUg5VDBBOXpxc3M&export=download" target="_blank">here</a>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7591391552778927829.post-76828958538032350822013-05-10T01:52:00.001-07:002013-05-10T02:16:30.213-07:00Azure Deployment Things to remember<div dir="ltr" style="text-align: left;" trbidi="on">
<div>
<span style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; border-collapse: separate; color: black; font-family: Tahoma; font-size: xx-small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="font-family: 'Times New Roman'; font-size: 16px;">Better guidance with screen shots pls check it</span></span><br />
<span style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; border-collapse: separate; color: black; font-family: Tahoma; font-size: xx-small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="font-family: 'Times New Roman'; font-size: 16px;"> ------------------------------------------------------</span></span><br />
<span style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; border-collapse: separate; color: black; font-family: Tahoma; font-size: xx-small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="font-family: 'Times New Roman'; font-size: 16px;"><a href="https://www.evernote.com/shard/s152/sh/6fc3a04f-6a7b-4938-b936-2e1e3ba16c87/8b9b7c1cdb959da88c1e24c5602dbb25">https://www.evernote.com/shard/s152/sh/6fc3a04f-6a7b-4938-b936-2e1e3ba16c87/8b9b7c1cdb959da88c1e24c5602dbb25</a> </span></span><br />
<a href="http://www.blogger.com/blogger.g?blogID=7591391552778927829" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="file:///C:/Users/NS05/AppData/Local/Temp/enhtmlclip/Image.png" style="cursor: move;" /></a><br />
<span style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; border-collapse: separate; color: black; font-family: Tahoma; font-size: xx-small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="font-family: 'Times New Roman'; font-size: 16px;">1. Need to delete existing deployment package from the hosted application by using manage.windowsazure.com</span></span><br />
<div style="font-size: 16px;">
<span style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; border-collapse: separate; color: black; font-family: Tahoma; font-size: xx-small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="font-family: 'Times New Roman';">2. Need to change local database string to colud application database string in web.config or app.config</span></span></div>
<div style="font-size: 16px;">
<span style="font-family: 'Times New Roman';">3.Need to install caching by using "Manage NuGet Packages for solution" by right click on solution </span></div>
<div>
</div>
<div>
<br /></div>
<div>
Search for azure caching in "NuGet" Online search... You will see "Windows Azure Caching" then click on "Install" button</div>
<div>
<br /></div>
<div>
<img height="600" src="file:///C:/Users/NS05/AppData/Local/Temp/enhtmlclip/Image(1).png" style="cursor: default;" width="900" /></div>
<div>
<br /></div>
<div style="font-size: 16px;">
<span style="font-family: 'Times New Roman';">After cache installation you will see the following content/commented content in web.config</span></div>
<div>
<br /></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> <</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">configSections</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> <</span></span> <span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">section</span></span> <span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">name</span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">=</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">dataCacheClients</span></span> <span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span> <span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">type</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">=</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span> <span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">allowLocation</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">=</span></span> <span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">true</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span> <span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">allowDefinition</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">=</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Everywhere</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">/></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> <</span></span> <span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">section</span></span> <span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">name</span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">=</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">cacheDiagnostics</span></span> <span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span> <span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">type</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">=</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Microsoft.ApplicationServer.Caching.AzureCommon.DiagnosticsConfigurationSection, Microsoft.ApplicationServer.Caching.AzureCommon</span></span> <span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span> <span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">allowLocation</span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">=</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">true</span></span> <span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span> <span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">allowDefinition</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">=</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Everywhere</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">/></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">configSections</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">></span></span></div>
<div>
<br /></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">dataCacheClients</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> <</span></span> <span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">dataCacheClient</span></span> <span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">name</span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">=</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">default</span></span> <span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> <</span></span> <span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">autoDiscover</span></span> <span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">isEnabled</span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">=</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">true</span></span> <span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span> <span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">identifier</span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">=</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">[cache cluster role name]</span></span> <span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">/></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> <!--</span></span> <span style="color: green; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><localCache isEnabled="true" sync="TimeoutBased" objectCount="100000" ttlValue="300" /></span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">--></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </</span></span> <span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">dataCacheClient</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">dataCacheClients</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> <</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">cacheDiagnostics</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> <</span></span> <span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">crashDump</span></span> <span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">dumpLevel</span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">=</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Off</span></span> <span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span> <span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">dumpStorageQuotaInMB</span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">=</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">100</span></span> <span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">/></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">cacheDiagnostics</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">></span></span></div>
<div>
<br /></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> <!--</span></span> <span style="color: green; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Windows Azure Caching session state provider</span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">--></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> <!--</span></span> <span style="color: green; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><sessionState mode="Custom" customProvider="AFCacheSessionStateProvider"></span></span></div>
<div align="left">
<span style="color: green; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> <providers></span></span></div>
<div align="left">
<span style="color: green; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> <add name="AFCacheSessionStateProvider" type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache" cacheName="default" dataCacheClientName="default" applicationName="AFCacheSessionState"/></span></span></div>
<div align="left">
<span style="color: green; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </providers></span></span></div>
<div align="left">
<span style="color: green; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </sessionState></span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">--></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> <!--</span></span> <span style="color: green; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Windows Azure Caching output caching provider</span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">--></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> <!--</span></span> <span style="color: green; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><caching></span></span></div>
<div align="left">
<span style="color: green; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> <outputCache defaultProvider="AFCacheOutputCacheProvider"></span></span></div>
<div align="left">
<span style="color: green; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> <providers></span></span></div>
<div align="left">
<span style="color: green; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> <add name="AFCacheOutputCacheProvider" type="Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider, Microsoft.Web.DistributedCache" cacheName="default" dataCacheClientName="default" applicationName="AFCacheOutputCache" /></span></span></div>
<div align="left">
<span style="color: green; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </providers></span></span></div>
<div align="left">
<span style="color: green; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </outputCache></span></span></div>
<div align="left">
<span style="color: green; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </caching></span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">--></span></span></div>
<div align="left" style="font-size: 16px;">
<span style="font-family: 'Times New Roman';"> Uncomment above 2 commented sections(Session State, Caching)</span></div>
<div align="left" style="font-size: 16px;">
<span style="font-family: 'Times New Roman';"> Need to change <span style="color: red;">identifier </span><span style="color: #a31515;"> </span>value(<span style="color: #010101;">"</span><span style="color: blue;">[cache cluster role name]</span> <span style="color: #010101;">"</span>) under <span style="color: #a31515;">autoDiscover</span> element to your project current role name.</span></div>
<div align="left" style="font-size: 16px;">
<span style="font-family: 'Times New Roman';">ex: My project Role Name: MyRole. then the identifier value will be "My Role";</span></div>
<div align="left">
<div style="font-size: 16px;">
<div>
<span style="font-family: 'Times New Roman';"><span style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; border-collapse: separate; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="text-align: -webkit-left;"><span style="color: blue;"> <</span> <span style="color: #a31515;">autoDiscover</span><span style="color: blue;"> </span><span style="color: red;">isEnabled</span> <span style="color: blue;">=</span><span style="color: #010101;"> "</span><span style="color: blue;">true</span> <span style="color: #010101;">"</span><span style="color: blue;"> </span><span style="color: red;">identifier</span> <span style="color: blue;">=</span><span style="color: #010101;"> "</span><span style="color: blue;">MyRole</span> <span style="color: #010101;">"</span><span style="color: blue;"> /></span></span></span></span></div>
<div>
<span style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; border-collapse: separate; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="text-align: -webkit-left;"><span style="color: blue;"><br /></span></span></span></div>
<div>
<span style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; border-collapse: separate; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="text-align: -webkit-left;"><span style="color: blue;"><br /></span></span></span></div>
<div>
<span style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; border-collapse: separate; color: black; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="text-align: -webkit-left;"><span style="color: blue;"><br /></span></span></span></div>
- Now go to web role configuration.</div>
<div>
<span style="font-family: 'Times New Roman'; font-size: 16px;"><br /></span>
<br />
<div style="font-size: 16px;">
<span style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; border-collapse: separate; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="text-align: -webkit-left;"><span style="font-family: 'Times New Roman';">- Enable caching for web role. Then double click on azure role and you will see "Caching" option then check "Enable caching" and specify the storage account credentials </span></span></span></div>
<div style="font-family: Consolas; font-size: 12px;">
<span style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; border-collapse: separate; font-family: Tahoma; font-size: xx-small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="text-align: -webkit-left;"><span style="font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><img height="544" src="file:///C:/Users/NS05/AppData/Local/Temp/enhtmlclip/Image(2).png" style="cursor: default;" width="1281" /></span></span></span></span></div>
<div style="font-size: 12px;">
<span style="font-family: Consolas;"><span style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; border-collapse: separate; color: black; font-family: Tahoma; font-size: xx-small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="text-align: -webkit-left;"><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><br /></span></span></span></span></span></div>
<div style="font-size: 12px;">
<span style="font-family: Consolas;"><span style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; border-collapse: separate; font-family: Tahoma; font-size: xx-small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="text-align: -webkit-left;"><span style="font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Check this link for caching info</span></span></span></span></span></div>
<div style="font-size: 12px;">
<span style="font-family: Consolas;"><span style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; border-collapse: separate; color: black; font-family: Tahoma; font-size: xx-small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="text-align: -webkit-left;"><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><a href="http://www.windowsazure.com/en-us/develop/net/how-to-guides/cache/">http://www.windowsazure.com/en-us/develop/net/how-to-guides/cache/</a></span></span></span></span></span></div>
<div style="font-size: 12px;">
<span style="font-family: Consolas;"><span style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; border-collapse: separate; color: black; font-family: Tahoma; font-size: xx-small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="text-align: -webkit-left;"><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><br /></span></span></span></span></span></div>
<span style="font-family: Consolas;"><span style="font-size: 12px;">-Set all the References "Copy Local" property to True</span></span></div>
<div>
<span style="color: blue; font-family: Consolas; font-size: 12px;"><img src="file:///C:/Users/NS05/AppData/Local/Temp/enhtmlclip/Image(3).png" style="cursor: default;" /></span></div>
</div>
<div align="left" style="font-size: 16px;">
<span style="font-family: 'Times New Roman';"><br /></span></div>
<div align="left" style="font-size: 16px;">
<span style="font-family: 'Times New Roman';">To Enable Win 32 Bit to your cloud application. Perform the following steps</span></div>
<div align="left" style="font-size: 16px;">
<span style="font-family: 'Times New Roman';">- Add Enable32BitAppPool file to your project and set "Copy to Output Directory " to "Copy Always"</span></div>
<div align="left" style="font-size: 16px;">
<span style="font-family: 'Times New Roman';"><br /></span></div>
<div align="left" style="font-size: 16px;">
<span style="font-family: 'Times New Roman';"><img src="file:///C:/Users/NS05/AppData/Local/Temp/enhtmlclip/Image(4).png" style="cursor: default;" /></span></div>
<div align="left" style="font-size: 16px;">
<span style="font-family: 'Times New Roman';"><br /></span></div>
<div align="left" style="font-size: 16px;">
<a href="http://www.blogger.com/null"><img src="file:///C:/Users/NS05/AppData/Local/Temp/enhtmlclip/EN015a2c15.png" /></a><span style="font-family: 'Times New Roman';"><br /></span></div>
<div align="left">
<span style="font-family: Consolas; font-size: 12px;"><br /></span></div>
<div align="left">
<span style="font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Add the following task line in "ServiceDefinition.csdef" file under </span></span><span style="font-family: Consolas; font-size: 12px;">Startup section :</span></div>
<div align="left">
<span style="font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">===============================================================================</span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><br /></span></span></div>
<div align="left">
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Startup</span></span> <span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">priority</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">=</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span> <span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">-2</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">></span></span></span></span></div>
</div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><Task commandLine="Enable32BitAppPool.cmd" executionContext="elevated" taskType="simple"><br />
</Task></span></span></div>
<div align="left">
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Startup</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">></span></span></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Import your colud profile to your application</span></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">- right click on your azure project and click on publish you will see publish dialog</span></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">- If your already downloaded your cloud application settings click on import</span></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;">- IF your not downloaded your cloud application settings click on "Sign in to download credentials" and download it and import it.</span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;">- Choose your subscription from the imported list.</span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><br /></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><img src="file:///C:/Users/NS05/AppData/Local/Temp/enhtmlclip/Image(5).png" style="cursor: default;" /></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><br /></span></span></span></div>
</div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><br /></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">- Click on next and ensure the cloud service and Check on "Enable Remote Desktop for all roles".</span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas;"><span style="font-size: 12px;"><img src="file:///C:/Users/NS05/AppData/Local/Temp/enhtmlclip/Image(6).png" style="cursor: default;" /></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas;"><span style="font-size: 12px;"><br /></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas;"><span style="font-size: 12px;">- Finally ensure all the configuration details and click on publish</span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas;"><span style="font-size: 12px;"><img src="file:///C:/Users/NS05/AppData/Local/Temp/enhtmlclip/Image(7).png" style="cursor: default;" /></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><br /></span></span></div>
<div>
Note: before starting publish. Close the other applications which consumes more virtual memory else you will get out of memory exception during the publish...</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
To enable SSL to your application </div>
<div>
=======================</div>
<div>
<br /></div>
<div>
<a href="http://www.windowsazure.com/en-us/develop/net/common-tasks/enable-ssl/">http://www.windowsazure.com/en-us/develop/net/common-tasks/enable-ssl/</a><br />
<br />
<br />
<br />
Reference Links for Azure Deployment:<br />
============================<br />
<a href="http://www.windowsazure.com/en-us/develop/net/tutorials/get-started/">http://www.windowsazure.com/en-us/develop/net/tutorials/get-started/</a><br />
<br />
<a href="http://www.windowsazure.com/en-us/manage/services/cloud-services/how-to-create-and-deploy-a-cloud-service/">http://www.windowsazure.com/en-us/manage/services/cloud-services/how-to-create-and-deploy-a-cloud-service/</a> </div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
</div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7591391552778927829.post-44913460237730489752013-04-03T20:38:00.001-07:002013-04-03T20:49:26.912-07:00Jquery basics<div dir="ltr" style="text-align: left;" trbidi="on">
Jquery Reference Links:<br />
=================<br />
<br />
Jquery UI:<br />
------------<br />
http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css<br />
http://code.jquery.com/ui/1.10.2/jquery-ui.js<br />
<br />
Jquery:<br />
---------<br />
http://code.jquery.com/jquery-1.9.1.js<br />
<br />
How to use page_init event(page loaded) in jquery:<br />
=====================================<br />
This will be used to execute initial script after complete page render. There are many ways available use page_init event in client side from that the following:<br />
$(document).ready(function() {<br /> // put all your Javascript/jQuery script in here.<br />});<br />
<br />
$(function(){<br />
<br />
// put all your Javascript/jQuery script in here. <br />
}); <br />
<br />
How to access element by using "Id" attribute:<br />
------------------------------------------------------<br />
<div id="dvmyelement" > Access element by using "Id" attribute: </div><br />
<br />
var myelement = $("#dvmyelement");<br />
<br />
<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7591391552778927829.post-64564344331284339872013-02-28T07:47:00.004-08:002013-02-28T07:47:53.127-08:00How find html tag and remove it from string in C#<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<br />
How find html tag from string in C#<br />
=========================<br />
<br />
Situation: i want to find and remove all the javascript from mystring. which can be like<br />
<br />
<script type="text/javascript" id="someid"><br />
<br />
.......Some functions goes here<br />
<br />
</script><br />
<br />
Now i want to remove all the script content from my string. The best way to remove script content is by using Regularexpression<br />
<br />
Regex reg=new Regex("<script (.+?)</script>");<br />
reg.Replace(test, "");<br />
<br />
Example:<br />
====== <br />
<br />
string test = "<script type='text/javascript'> Some functions goes here </script> A C# string is an array of characters declared using the string keyword. A string literal is declared using quotation marks, as shown in the following example: ";<br /> test += " <br/> You can extract substrings, and concatenate strings, like this:";<br /> test += "<script> another text </script> <br /> String objects are immutable, meaning that they cannot be changed once they have been created. Methods that act on strings actually return new string objects. In the previous example, when the contents of s1 and s2 are concatenated to form a single string, the two strings containing \"orange\" and \"red\" are both unmodified. The += operator creates a new string that contains the combined contents. The result is that s1 now refers to a different string altogether. A string containing just \"orange\" still exists, but is no longer referenced when s1 is concatenated.";<br /> Regex reg=new Regex("<script (.+?)</script>");<br /><br /> reg.Replace(test, "");<br />
<br />
response.write(test);</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7591391552778927829.post-43568524105261836382013-02-27T20:52:00.002-08:002013-02-27T20:52:42.527-08:00How To Date filter with Devexpress XPO XPDataView<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div>
<span style="border-collapse: separate; border-spacing: 0px; font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;"><br /></span></div>
<div>
<span style="border-collapse: separate; border-spacing: 0px; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-family: Tahoma;">How To Date filter with Devexpress XPO XPDataView</span></span></div>
<div>
<span style="border-collapse: separate; border-spacing: 0px; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-family: Tahoma;"><br /></span></span></div>
<div>
<span style="border-collapse: separate; border-spacing: 0px; font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;"><br /></span></div>
<div>
<span style="border-collapse: separate; border-spacing: 0px; font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;"><br /></span></div>
<div>
<span style="border-collapse: separate; border-spacing: 0px; font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;"><br /></span></div>
<div>
<span style="border-collapse: separate; border-spacing: 0px; font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;"> public string GetCreatedDate(string period, string column, string customFilterFrom = null, string CustomFilterTo = null)<br />
{<br />
<br />
string date = string.Empty; string filterexp = string.Empty;<br />
DateTime dt = DateTime.Today;<br />
switch (period.ToUpper())<br />
{<br /><br />
case "CUSTOM":<br />
date = new BetweenOperator(column, Convert.ToDateTime(customFilterFrom.Replace("/", "-")), Convert.ToDateTime(CustomFilterTo.Replace("/", "-"))).ToString();<br /><br />
break;<br />
case "TODAY":<br />
date = new BetweenOperator(column, dt, dt.AddDays(1)).ToString(); //string.Format("[{1}] = #{0}#", dt, column);//.ToString("MM/dd/yyyy")<br />
break;<br />
case "LASTDAY":<br />
date = new BetweenOperator(column,dt.AddDays(-1),dt).ToString();<br />
break;<br />
case "THISYEAR":<br />
date = new BetweenOperator(column, new DateTime(DateTime.Now.Year, 4, 1), dt.AddDays(1)).ToString();<br />
break;<br /><br />
case "THISMONTH":<br />
date = new BetweenOperator(column, new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1), dt.AddDays(1)).ToString();<br />
break;<br />
case "LASTMONTH":<br />
date = new BetweenOperator(column, new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(-1), new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).AddDays(-1)).ToString();<br />
<br />
break;<br />
case "THISWEEK":<br />
int days = (DateTime.Now.DayOfWeek - DayOfWeek.Sunday) - 1;<br />
DateTime thisweek = DateTime.Now.AddDays(-(days));<br />
date = new BetweenOperator(column, thisweek, thisweek.AddDays(days)).ToString();<br />
break;<br />
case "LASTWEEK":<br />
int diff = (DateTime.Now.DayOfWeek - DayOfWeek.Sunday) + 6;<br />
DateTime mondayOfLastWeek = DateTime.Now.AddDays(-diff);<br />
date = new BetweenOperator(column, mondayOfLastWeek, mondayOfLastWeek.AddDays(diff -6)).ToString();<br />
break;<br />
default:<br />
date = string.Format("[{0}] = '{1}'", column, period);<br />
break;<br /><br />
}<br />
return date;<br />
}</span></div>
<div>
<span style="border-collapse: separate; border-spacing: 0px; font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;"><br /></span></div>
<div>
<span style="border-collapse: separate; border-spacing: 0px; font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;"><br /></span></div>
<div>
<span style="border-collapse: separate; border-spacing: 0px; font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;"><br /></span></div>
<div>
<span style="border-collapse: separate; border-spacing: 0px; font-family: Tahoma; orphans: 2; text-align: -webkit-auto; widows: 2;">Refer my original post in devexpress : <a href="http://www.devexpress.com/Support/Center/Question/Details/Q477778" target="_blank">Unable to filter date values in xpo DataSource</a></span></div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7591391552778927829.post-55751825108074939662012-11-29T21:47:00.003-08:002012-11-29T21:47:41.039-08:00Free Heart Surgery for children<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
Free Heart Surgery for children</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-SfBm0L5M0eY/ULhIQbWiccI/AAAAAAAAAHQ/lIw_-P3W30c/s1600/600070_409587672445200_143034586_n.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-SfBm0L5M0eY/ULhIQbWiccI/AAAAAAAAAHQ/lIw_-P3W30c/s1600/600070_409587672445200_143034586_n.jpg" /></a></div>
<br />
<div>
<br /></div>
<div>
Source : https://www.facebook.com/photo.php?fbid=409587672445200&set=a.152699364800700.37093.151360824934554&type=1&theater</div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7591391552778927829.post-55033889170158529312012-08-22T03:07:00.004-07:002012-08-22T03:07:37.264-07:00The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine. in Server<div dir="ltr" style="text-align: left;" trbidi="on">
There are times when the coexistence of 64 and 32 bit code on the same machine can cause all sorts of seemingly strange issues.<br />
One of them just occurred to me while trying to run the <a href="http://www.devexpress.com/Downloads/NET/OnlineDemos.xml">ASPx demos</a> from <a href="http://www.devexpress.com/">Developer Express</a>, my main provider of .Net components (the best supplier I’ve ever been able to find).<br />
I was getting the following error:
<br />
<em>The ‘Microsoft.Jet.OLEDB.4.0′ provider is not registered on the local machine:</em>
<br />
<center>
<img alt="Server Error" src="http://blog.nkadesign.com/wp-content/uploads/2008/10/sshot-2.png" /></center>
It may look otherwise, but this error is generally due to either of two thing:<br />
<ul>
<li>you don’t have Office 2007/2010 Jet drivers installed</li>
<li>or you are running a 32 bit application in a default x64 environment.</li>
</ul>
The first issue is easy to solve, just download the <a href="http://www.microsoft.com/download/en/details.aspx?id=13255">Access 2010 Database Engine</a> from Microsoft (works with Access 2007 databases as well).<br />
For the second one, the fix is also easy enough:<br />
<ul>
<li><em>For Windows 2008</em>: Navigate to Server Manager > Roles
> Web Server (IIS) > Internet Information Services (IIS) Manager,
then look under your machine name > Application Pool.</li>
<li><em>For Windows 7</em>: Navigate to Programs > Administrative
Tools > Internet Information Services (IIS) Manager, then look under
your machine name > Application Pool.</li>
</ul>
<center>
<a href="http://blog.nkadesign.com/wp-content/uploads/2008/10/sshot-6.png" rel="lightbox" style="border: 0;" title="Server Manager"><img height="410" src="http://blog.nkadesign.com/wp-content/uploads/2008/10/sshot-6sm.png" title="Server Manager" width="560" /></a></center>
Under there you can call the DefaultAppPool’s advanced settings to change <code>Enable 32-Bits Applications</code> to <code>True</code>:<br />
<br />
<center>
<img alt="Advanced Settings" src="http://blog.nkadesign.com/wp-content/uploads/2008/10/sshot-3.png" /></center>
You may have to restart the service for it to take effect but it should work.<br />
<br />
Source: <a href="http://blog.nkadesign.com/2008/windows-2008-the-microsoftjetoledb40-provider-is-not-registered-on-the-local-machine/" target="_blank">http://blog.nkadesign.com</a> </div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7591391552778927829.post-20623843558156672112012-07-27T08:10:00.000-07:002012-07-27T08:10:08.864-07:00How to show aspxpopup control on button click instead of enter key press<div dir="ltr" style="text-align: left;" trbidi="on">
Steps:<br />
==== <br />
1. I have two textboxes and one button and one aspxpopupcontrol in a aspxwebpage<br />
2. I attached Keypress event for two textboxes and i have attached button OnClientClick event from C# code behind to show aspxpopupcontrol.<br />
3. Here problem is when ever i enter some data in any one of the text and press enter it is executing textbox keypress event as well as it showing aspxpopupcontrol. it very annoying to the user.<br />
4. I resolved this issue by using the following devexpress client side method in textbox keypress event.<br />
<span style="color: #073763;"> <b> ASPxClientUtils.PreventEventAndBubble(e.htmlEvent);</b></span><br />
<br />
<span style="color: #073763;"><b> </b></span>Example:<br />
========<br />
<br />
<dx:ASPxTextBox runat="server" ID="txtSearch" ClientInstanceName="txtSearch" NullText="Search by Text" Style="border-radius: 4px 4px 4px 4px;"><br />
<ClientSideEvents KeyPress="function(s,e){ <br />
var keypressed=ASPxClientUtils.GetKeyCode(e.htmlEvent);<br /> if(keypressed ==13)<br /> { <br /> //Your client side functionality goes here<br /> ASPxClientUtils.PreventEventAndBubble(e.htmlEvent);<br /> }}" /><br />
</dx:ASPxTextBox> <br />
<br />
<dx:ASPxTextBox runat="server" ID="txtTagSearch"
ClientInstanceName="txtTagSearch" NullText="Search by Tag"
Style="border-radius: 4px 4px 4px 4px;"><br />
<ClientSideEvents KeyPress="function(s,e){ <br />
var keypressed=ASPxClientUtils.GetKeyCode(e.htmlEvent);<br /> if(keypressed ==13)<br /> { <br /> //Your client side functionality goes here<br /> ASPxClientUtils.PreventEventAndBubble(e.htmlEvent);<br /> }}" /><br />
</dx:ASPxTextBox> <br />
<div style="color: black;">
<br /></div>
<div style="color: black;">
<asp:ImageButton ID="btnShowCustomViewBuilder" CausesValidation="true" runat="server" ImageUrl="~/Styles/Images/FilterIcon.png"<br /> OnClientClick=" popup.Show(); return false" /> </div>
<div style="color: black;">
<br /></div>
<div style="color: black;">
<dx:ASPxPopupControl ID="AspxPopupControl1" runat="server" Modal="True" AutoUpdatePosition="true" HeaderStyle-Font-Bold="true"<br /> PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" AllowDragging="true" AccessibilityCompliant="false" <br /> ShowLoadingPanel="false" HeaderText="Example Popup" ClientInstanceName="popup" PopupAction="LeftMouseClick" <br /> Width="520px"><br /> <ContentCollection><br /> <dx:PopupControlContentControl ID="PopupControlContentControl3" runat="server" SupportsDisabledAttribute="True"></div>
<div style="color: black;">
<br /></div>
<div style="color: black;">
<table></div>
<div style="color: black;">
<tr></div>
<div style="color: black;">
<td> //Your content goes here </td> </div>
<div style="color: black;">
</tr></div>
<div style="color: black;">
</table></div>
<div style="color: black;">
<br /></div>
<span style="color: #073763;"><span style="color: black;"> </dx:PopupControlContentControl></span><br style="color: black;" /><span style="color: black;"> </ContentCollection></span><br style="color: black;" /><span style="color: black;"></dx:ASPxPopupControl></span><b><br /></b></span><br />
<br />
<b><a href="http://www.devexpress.com/Support/Center/p/Q388779.aspx" target="_blank">Reference to resolve above issue</a></b><br />
<br />
Please let me know if you have any doubts on this.</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7591391552778927829.post-14820466264008257702012-07-23T05:23:00.000-07:002012-07-23T05:23:20.126-07:00How to Display row value as Column Name in SQL Server<div dir="ltr" style="text-align: left;" trbidi="on">
Static Query:<br />
========= <br />
<br />
SELECT branch1,branch2,Name,Id FROM (SELECT top 5 tb.* from Users as tb <br /> ) AS PivotData<br />PIVOT (COUNT(Location) FOR Branch IN (branch1,branch2) ) AS PivotTabllumns <br /><br />
<br />
Dynamic Query:<br />
============<br />
<br />
<br />
'SELECT * FROM (SELECT top 5 tb.* from ' + TableName + ' as tb <br />
) AS PivotData <br />
PIVOT (COUNT(' + Columns +') FOR ' + Columns +' IN ( ' + CColumns + ') ) AS PivotTable'<br />
<br />
<br />
///Above Columns and CColumns and TableName are the local variables which are picked from temp table<br />
<br />
Instead of "TableName" value you need to pass your table name<br />
Instead of "Columns" On which column(ex: ID,Reference No or any column etc....) you need to perform operation<br />
Instead of "CColumns" you have to pass your own values ex: if your checking for branch count you need to pass branch name values i.e: branch1, branch2, branch3<br />
<br />
If you have any doubts please let me know. <br />
<br />
Result :<br />
=======<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-DrAf8sC-P8Y/UA1B_p8l86I/AAAAAAAAAG4/cSlerlVqj28/s1600/PivotTable.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-DrAf8sC-P8Y/UA1B_p8l86I/AAAAAAAAAG4/cSlerlVqj28/s1600/PivotTable.PNG" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-F09vvjcgFX8/UA1B-9Uy4rI/AAAAAAAAAGw/RgpCWjteydk/s1600/PivotResult.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="374" src="http://2.bp.blogspot.com/-F09vvjcgFX8/UA1B-9Uy4rI/AAAAAAAAAGw/RgpCWjteydk/s640/PivotResult.PNG" width="640" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br /></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7591391552778927829.post-26734638761517968642012-06-28T06:07:00.000-07:002012-06-28T06:07:14.414-07:00Displaying a context menu for Column Headers of an AspxGridView<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<pre class="default prettyprint" style="background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; line-height: 18px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">It</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">is</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> possible we can create context menu on aspxgridview</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Find</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> the following example </span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">for</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> aspxgridview context menu</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Default</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">aspx</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">:</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=============</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"><</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">dx</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">:</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">ASPxGridView</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> ID</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="str" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;">"grvContexMenuExample"</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> runat</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="str" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;">"server"</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">AutoGenerateColumns</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="str" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;">"false"</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">KeyFieldName</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="str" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;">"ID"</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">EnableViewState</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="str" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;">"true"</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">ClientInstanceName</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="str" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;">"grdtest"</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Width</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="str" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;">"100%"</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Settings</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">-</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">GridLines</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="str" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;">"None"</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">OnHtmlRowPrepared</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="str" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;">"grvContexMenuExample_HtmlRowPrepared"</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">></span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"><</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">ClientSideEvents</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">ContextMenu</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="str" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;">"function(s,e) {
if(e.objectType == 'header')
{
headerContextMenu.ShowAtPos(e.htmlEvent.clientX, e.htmlEvent.clientY);
}
else if(e.objectType == 'row')
{
headerContextMenu.ShowAtPos(e.htmlEvent.clientX, e.htmlEvent.clientY);
}
}"</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">/></span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"><</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Columns</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">></span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"><%--</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Your</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> columns goes here</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">--%></span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="str" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;"><columns></span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"><</span><span class="str" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;">/dx:ASPxGridView>
<!--Start New Context Menu !-->
<dx:ASPxPopupMenu ID="mnContextMenu" runat="server" ClientInstanceName="headerContextMenu"
EnableAnimation="false" PopupHorizontalAlign="OutsideRight" PopupVerticalAlign="TopSides"
PopupAction="RightMouseClick">
<Items>
<dx:MenuItem Text="New Context Menu1">
</</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">dx</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">:</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">MenuItem</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">></span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"><</span><span class="str" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;">/Items>
<ClientSideEvents ItemClick="ContextMenuItemClick" /</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">></span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"></</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">dx</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">:</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">ASPxPopupMenu</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">></span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"><!--</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">End</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">New</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Context</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Menu</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">!--></span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Default</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">aspx</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">cs</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">:</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">================</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">protected</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">void</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> grvContexMenuExample_HtmlRowPrepared</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">object</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> sender</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">ASPxGridViewTableRowEventArgs</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> e</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">{</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">if</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">e</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">RowType</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">==</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">GridViewRowType</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Data</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">if</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">e</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">RowType</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">==</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">GridViewRowType</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Header</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">{</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
e</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Row</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Attributes</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">Remove</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="str" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;">"oncontextmenu"</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">}</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">}</span></code></pre>
</div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-7591391552778927829.post-10781620594212398052012-06-20T01:31:00.001-07:002012-06-20T01:31:25.106-07:00How to Convert Stream/Xml To DataSet/Datatable<div dir="ltr" style="text-align: left;" trbidi="on">
public static DataSet GetDatasetFromExcel(string FileName)<br /> {<br /> bool hasHeaders = true;<br /> string HDR = hasHeaders ? "Yes" : "No";<br /> string strConn;<br /> if (FileName.Substring(FileName.LastIndexOf('.')).ToLower() == ".xlsx")<br /> strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FileName + ";Extended Properties=\"Excel 12.0;HDR=" + HDR + ";IMEX=0\"";<br /> else<br /> strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FileName + ";Extended Properties=\"Excel 8.0;HDR=" + HDR + ";IMEX=0\"";<br /><br /> DataSet output = new DataSet();<br /><br /> using (OleDbConnection conn = new OleDbConnection(strConn))<br /> {<br /> conn.Open();<br /><br /> DataTable schemaTable = conn.GetOleDbSchemaTable(<br /> OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });<br /><br /> foreach (DataRow schemaRow in schemaTable.Rows)<br /> {<br /> string sheet = schemaRow["TABLE_NAME"].ToString();<br /><br /> if (!sheet.EndsWith("_"))<br /> {<br /> try<br /> {<br /> OleDbCommand cmd = new OleDbCommand("SELECT * FROM [" + sheet + "]", conn);<br /> cmd.CommandType = CommandType.Text;<br /><br /> DataTable outputTable = new DataTable(sheet);<br /> output.Tables.Add(outputTable);<br /> new OleDbDataAdapter(cmd).Fill(outputTable);<br /> }<br /> catch (Exception ex)<br /> {<br /> throw new Exception(ex.Message + string.Format("Sheet:{0}.File:F{1}", sheet, FileName), ex);<br /> }<br /> }<br /> }<br /> }<br /> return output;<br /> }</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7591391552778927829.post-53989350356010255822012-06-19T09:55:00.001-07:002012-06-19T09:55:46.910-07:00How to convert object[] to List<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<pre style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #eeeeee; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 16px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; max-height: 600px; orphans: 2; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; widows: 2; width: auto; word-spacing: 0px;"><span style="border-collapse: separate; color: black; font-family: Tahoma; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><code style="background-color: #eeeeee; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"><span style="background-color: transparent; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #2b91af; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">List</span><span style="background-color: transparent; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: maroon; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"><string></span><span style="background-color: transparent; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"> fields </span><span style="background-color: transparent; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">=</span><span style="background-color: transparent; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"> values</span><span style="background-color: transparent; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">.</span><span style="background-color: transparent; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #2b91af; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">Select</span><span style="background-color: transparent; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">(</span><span style="background-color: transparent; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">i </span><span style="background-color: transparent; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">=></span><span style="background-color: transparent; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"> i</span><span style="background-color: transparent; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">.</span><span style="background-color: transparent; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #2b91af; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">ToString</span><span style="background-color: transparent; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">()).</span><span style="background-color: transparent; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #2b91af; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">ToList</span><span style="background-color: transparent; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">();</span></code></span></pre>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7591391552778927829.post-9346131209720936612012-06-19T09:49:00.000-07:002012-06-19T09:49:10.204-07:00Solution for the error "Sys.WebForms.PageRequestManagerServerErrorException"<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr><td><b>Web.Config</b></td><td width="60"> </td><td> </td></tr>
<tr><td height="11"><br /></td><td height="11" width="60"><br /></td><td height="11"><img height="11" width="11" /></td></tr>
<tr><td> A number of configuration settings become very relevant when performing uploads. These can be changed by adding sections or values into the Web.Config file. A typical configuration section is given below.<br />
<code><system.web><br />
<httpModules><br />
<add name="Progress" type="WebSupergoo.ABCUpload5.ProgressModule, ABCUpload5, Version=5.3.0.0, Culture=neutral, PublicKeyToken=1f89539196ce5fbf"/><br />
</httpModules><br /><br />
<compilation><br />
<assemblies><br />
<add assembly="ABCUpload5, Version=5.3.0.0, Culture=neutral, PublicKeyToken=1f89539196ce5fbf" /><br />
</assemblies><br />
</compilation><br /><br />
<httpRuntime<br />
maxRequestLength="1048576"<br />
executionTimeout="3600"<br />
/><br /><br />
<sessionState<br />
timeout="60"<br />
/><br />
...</code><br />
<h2>
httpModules sub-tag</h2>
The Progress Module is required for the Pure HTML Progress Bar, for GigUpload and for Corruption Autofix functionality. The Progress Module is a .NET HTTP Module designed to intercept page requests and preprocess them before passing them on to ASP.NET.<br />
To integrate the Progress Module into your ASP.NET application you need to add it using a line in the httpModules subsection of the web.config file. This is shown in the example web.config file above.<br />
<h2>
compilation sub-tag</h2>
To integrate and use ABCUpload objects into your ASP.NET application you need to add a reference to the assembly (stored in the GAC) using a line in the compilation subsection of the web.config file. This is shown in the example web.config file above<br />
<h2>
httpRuntime maxRequestLength</h2>
This attribute is used to limit the size of uploads by rejecting any which exceed a certain limit. The limit refers to the total size of the HTTP upload in KB (approximately equal to the sum of all the files being upload). You should set a sensible limit here to stop malicious visitors using up your bandwidth by uploading excessively large files.<br />
If the size of an upload is too great the server will refuse to accept it. Because the server is refusing the request the uploading browser will report that the submission page is not available. This is a client side error message rather than a server side error message and it means that you cannot normally provide a sensible error message to users if they submit files which are too large.<br />
However using ABCUpload you can report back a sensible error message via a progress window. If you believe that visitors may attempt to perform uploads greater than the maximum you should use the progress bar and the note on the progress window will inform your visitor why their upload has been rejected.<br />
In the example web.config file above the maxRequestLength is set to 1 GB.<br />
<h2>
httpRuntime executionTimeout</h2>
The execution time-out refers to the number of seconds an ASP.NET page is given before the operation is assumed to have failed and the page terminated. If you are uploading a large file the code that is receiving the transfer may time out before the file has been completely uploaded.<br />
In the example web.config file above the executionTimeout is set to one hour.<br />
<h2>
sessionState timeout</h2>
The session time-out refers to the number of minutes before the user session is aborted. If a large file is being uploaded it is desirable to maintain the session state. The session time-out should always be longer than the amount of time you expect uploads to take. Note that this value is only relevant if you have session state enabled.<br />
In the example web.config file above the sessionState is set to one hour.<br />
<h2>
processModel responseDeadlockInterval</h2>
The responseDeadlockInterval is specified in the machine.config file and defaults to three minutes. It specifies the time interval after which the process will be restarted if no responses have been made and requests are still queued.<br />
Under ASP.NET requests that take longer than the deadlock interval can cause problems under some very specific circumstances. Sometimes a client may make multiple page requests which ASP.NET may queue one after the other. If the first request in the queue takes longer than the deadlock interval then ASP.NET will mistakenly assume the whole process is deadlocked and restart it. These types of situation are very unusual and are more commonly encountered in test environments than real world ones.<br />
For this situation to arise a client must make multiple uploads simultaneously. At least two uploads must take longer than the timeout. The client must make other page requests at the same time which IIS must decide to queue (whether it decides to queue them or not depends on whether IIS thinks they form part of the same session). These queued requests must not time out or be dismissed on the client side. Neither the client nor any other visitors must make other aspx page requests during this time.</td></tr>
</tbody></table>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7591391552778927829.post-71422491240444264712012-06-19T09:48:00.002-07:002012-06-19T09:59:47.855-07:00How to Find First and Last Day of Current Month<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div align="left">
<span style="border-collapse: separate; color: black; font-family: Tahoma; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">DECLARE</span></span> <span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">@mydate</span></span> <span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">DATETIME</span></span></span></div>
<div align="left">
<span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">SELECT</span></span> <span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">@mydate</span></span> <span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">=</span></span> <span style="color: magenta; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">GETDATE</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">()</span></span></div>
<div align="left">
<span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">SELECT</span></span> <span style="color: magenta; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">CONVERT</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">VARCHAR</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">25</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">),</span></span><span style="color: magenta; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">DATEADD</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">dd</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">,-(</span></span><span style="color: magenta; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">DAY</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">@mydate</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">)),</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">@mydate</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">),</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">101</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">)</span></span> <span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">,</span></span></div>
<div align="left">
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">'Last Day of Previous Month'</span></span></div>
<div align="left">
<span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">UNION</span></span></div>
<div align="left">
<span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">SELECT</span></span> <span style="color: magenta; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">CONVERT</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">VARCHAR</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">25</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">),</span></span><span style="color: magenta; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">DATEADD</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">dd</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">,-(</span></span><span style="color: magenta; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">DAY</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">@mydate</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">)-</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">1</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">),</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">@mydate</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">),</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">101</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">)</span></span> <span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">AS</span></span> <span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">Date_Value</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">,</span></span></div>
<div align="left">
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">'First Day of Current Month'</span></span> <span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">AS</span></span> <span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">Date_Type</span></span></div>
<div align="left">
<span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">UNION</span></span></div>
<div align="left">
<span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">SELECT</span></span> <span style="color: magenta; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">CONVERT</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">VARCHAR</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">25</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">),</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">@mydate</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">,</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">101</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">)</span></span> <span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">AS</span></span> <span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">Date_Value</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">,</span></span> <span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">'Today'</span></span> <span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">AS</span></span> <span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">Date_Type</span></span></div>
<div align="left">
<span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">UNION</span></span></div>
<div align="left">
<span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">SELECT</span></span> <span style="color: magenta; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">CONVERT</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">VARCHAR</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">25</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">),</span></span><span style="color: magenta; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">DATEADD</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">dd</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">,-(</span></span><span style="color: magenta; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">DAY</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: magenta; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">DATEADD</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">mm</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">,</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">1</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">,</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">@mydate</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">))),</span></span><span style="color: magenta; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">DATEADD</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">mm</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">,</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">1</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">,</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">@mydate</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">)),</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">101</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">)</span></span> <span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">,</span></span></div>
<div align="left">
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">'Last Day of Current Month'</span></span></div>
<div align="left">
<span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">UNION</span></span></div>
<div align="left">
<span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">SELECT</span></span> <span style="color: magenta; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">CONVERT</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">VARCHAR</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">25</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">),</span></span><span style="color: magenta; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">DATEADD</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">dd</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">,-(</span></span><span style="color: magenta; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">DAY</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: magenta; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">DATEADD</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">mm</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">,</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">1</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">,</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">@mydate</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">))-</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">1</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">),</span></span><span style="color: magenta; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">DATEADD</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">mm</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">,</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">1</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">,</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">@mydate</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">)),</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">101</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">)</span></span> <span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">,</span></span></div>
<div align="left">
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">'First Day of Next Month'</span></span></div>
<div align="left">
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"><br /></span></span></div>
<div align="left">
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">--------------------------------------------------------------------------------------------------</span></span></div>
<div align="left">
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"><br /></span></span></div>
<div align="left">
<div>
<div style="text-align: justify;">
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"><code style="font-size: 12px;"><span style="color: green;">----Today</span></code></span></span><br />
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"><code style="font-size: 12px;"><span style="color: blue;">SELECT</span><span style="color: magenta;"> GETDATE</span><span style="color: grey;">()</span> </code></span></span><br />
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"><code style="font-size: 12px;"> <span style="color: red;">'Today'</span></code></span></span><br />
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"><code style="font-size: 12px;"><span style="color: red;"> </span><span style="color: green;">----Yesterday</span><span style="color: blue;">SELECT</span> <span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">d</span><span style="color: grey;">,-</span><span style="color: black;">1</span><span style="color: grey;">,</span><span style="color: magenta;">GETDATE</span><span style="color: grey;">())</span> <span style="color: red;">'Yesterday'</span><span style="color: green;"> </span></code></span></span><br />
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"><code style="font-size: 12px;"><span style="color: green;">----First Day of Current Week</span><span style="color: blue;">SELECT</span> <span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">wk</span><span style="color: grey;">,</span><span style="color: magenta;">DATEDIFF</span><span style="color: grey;">(</span><span style="color: black;">wk</span><span style="color: grey;">,</span><span style="color: black;">0</span><span style="color: grey;">,</span><span style="color: magenta;">GETDATE</span><span style="color: grey;">()),</span><span style="color: black;">0</span><span style="color: grey;">)</span> <span style="color: red;">'First Day of Current Week'</span></code></span></span><br />
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"><code style="font-size: 12px;"><span style="color: red;"> </span><span style="color: green;">----Last Day of Current Week</span><span style="color: blue;">SELECT</span> <span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">wk</span><span style="color: grey;">,</span><span style="color: magenta;">DATEDIFF</span><span style="color: grey;">(</span><span style="color: black;">wk</span><span style="color: grey;">,</span><span style="color: black;">0</span><span style="color: grey;">,</span><span style="color: magenta;">GETDATE</span><span style="color: grey;">()),</span><span style="color: black;">6</span><span style="color: grey;">)</span> <span style="color: red;">'Last Day of Current Week'</span><span style="color: green;"> </span></code></span></span><br />
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"><code style="font-size: 12px;"><span style="color: green;">----First Day of Last Week</span><span style="color: blue;">SELECT</span> <span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">wk</span><span style="color: grey;">,</span><span style="color: magenta;">DATEDIFF</span><span style="color: grey;">(</span><span style="color: black;">wk</span><span style="color: grey;">,</span><span style="color: black;">7</span><span style="color: grey;">,</span><span style="color: magenta;">GETDATE</span><span style="color: grey;">()),</span><span style="color: black;">0</span><span style="color: grey;">)</span> <span style="color: red;">'First Day of Last Week'</span><span style="color: green;"> </span></code></span></span><br />
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"><code style="font-size: 12px;"><span style="color: green;">----Last Day of Last Week</span><span style="color: blue;">SELECT</span> <span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">wk</span><span style="color: grey;">,</span><span style="color: magenta;">DATEDIFF</span><span style="color: grey;">(</span><span style="color: black;">wk</span><span style="color: grey;">,</span><span style="color: black;">7</span><span style="color: grey;">,</span><span style="color: magenta;">GETDATE</span><span style="color: grey;">()),</span><span style="color: black;">6</span><span style="color: grey;">)</span> <span style="color: red;">'Last Day of Last Week'</span><span style="color: green;"> </span></code></span></span><br />
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"><code style="font-size: 12px;"><span style="color: green;">----First Day of Current Month</span><span style="color: blue;">SELECT</span> <span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">mm</span><span style="color: grey;">,</span><span style="color: magenta;">DATEDIFF</span><span style="color: grey;">(</span><span style="color: black;">mm</span><span style="color: grey;">,</span><span style="color: black;">0</span><span style="color: grey;">,</span><span style="color: magenta;">GETDATE</span><span style="color: grey;">()),</span><span style="color: black;">0</span><span style="color: grey;">)</span> <span style="color: red;">'First Day of Current Month'</span><span style="color: green;"> </span></code></span></span><br />
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"><code style="font-size: 12px;"><span style="color: green;">----Last Day of Current Month</span><span style="color: blue;">SELECT</span> <span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">ms</span><span style="color: grey;">,-</span> <span style="color: black;">3</span><span style="color: grey;">,</span><span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">mm</span><span style="color: grey;">,</span><span style="color: black;">0</span><span style="color: grey;">,</span><span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">mm</span><span style="color: grey;">,</span><span style="color: magenta;">DATEDIFF</span><span style="color: grey;">(</span><span style="color: black;">mm</span><span style="color: grey;">,</span><span style="color: black;">0</span><span style="color: grey;">,</span><span style="color: magenta;">GETDATE</span><span style="color: grey;">())+</span><span style="color: black;">1</span><span style="color: grey;">,</span><span style="color: black;">0</span><span style="color: grey;">)))</span> <span style="color: red;">'Last Day of Current Month'</span></code></span></span><br />
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"><code style="font-size: 12px;"><span style="color: red;"> </span><span style="color: green;">----First Day of Last Month</span><span style="color: blue;">SELECT</span> <span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">mm</span><span style="color: grey;">,-</span><span style="color: black;">1</span><span style="color: grey;">,</span><span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">mm</span><span style="color: grey;">,</span><span style="color: magenta;">DATEDIFF</span><span style="color: grey;">(</span><span style="color: black;">mm</span><span style="color: grey;">,</span><span style="color: black;">0</span><span style="color: grey;">,</span><span style="color: magenta;">GETDATE</span><span style="color: grey;">()),</span><span style="color: black;">0</span><span style="color: grey;">))</span> <span style="color: red;">'First Day of Last Month'</span></code></span></span><br />
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"><code style="font-size: 12px;"><span style="color: red;"> </span><span style="color: green;">----Last Day of Last Month</span><span style="color: blue;">SELECT</span> <span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">ms</span><span style="color: grey;">,-</span><span style="color: black;">3</span><span style="color: grey;">,</span><span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">mm</span><span style="color: grey;">,</span><span style="color: black;">0</span><span style="color: grey;">,</span><span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">mm</span><span style="color: grey;">,</span><span style="color: magenta;">DATEDIFF</span><span style="color: grey;">(</span><span style="color: black;">mm</span><span style="color: grey;">,</span><span style="color: black;">0</span><span style="color: grey;">,</span><span style="color: magenta;">GETDATE</span><span style="color: grey;">()),</span><span style="color: black;">0</span><span style="color: grey;">)))</span> <span style="color: red;">'Last Day of Last Month'</span></code></span></span><br />
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"><code style="font-size: 12px;"><span style="color: red;"> </span><span style="color: green;">----First Day of Current Year</span><span style="color: blue;">SELECT</span> <span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">yy</span><span style="color: grey;">,</span><span style="color: magenta;">DATEDIFF</span><span style="color: grey;">(</span><span style="color: black;">yy</span><span style="color: grey;">,</span><span style="color: black;">0</span><span style="color: grey;">,</span><span style="color: magenta;">GETDATE</span><span style="color: grey;">()),</span><span style="color: black;">0</span><span style="color: grey;">)</span> <span style="color: red;">'First Day of Current Year'</span><span style="color: green;"> </span></code></span></span><br />
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"><code style="font-size: 12px;"><span style="color: green;">----Last Day of Current Year</span><span style="color: blue;">SELECT</span> <span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">ms</span><span style="color: grey;">,-</span><span style="color: black;">3</span><span style="color: grey;">,</span><span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">yy</span><span style="color: grey;">,</span><span style="color: black;">0</span><span style="color: grey;">,</span><span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">yy</span><span style="color: grey;">,</span><span style="color: magenta;">DATEDIFF</span><span style="color: grey;">(</span><span style="color: black;">yy</span><span style="color: grey;">,</span><span style="color: black;">0</span><span style="color: grey;">,</span><span style="color: magenta;">GETDATE</span><span style="color: grey;">())+</span><span style="color: black;">1</span><span style="color: grey;">,</span><span style="color: black;">0</span><span style="color: grey;">)))</span> <span style="color: red;">'Last Day of Current Year'</span><span style="color: green;"> </span></code></span></span><br />
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"><code style="font-size: 12px;"><span style="color: green;">----First Day of Last Year</span><span style="color: blue;">SELECT</span> <span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">yy</span><span style="color: grey;">,-</span><span style="color: black;">1</span><span style="color: grey;">,</span><span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">yy</span><span style="color: grey;">,</span><span style="color: magenta;">DATEDIFF</span><span style="color: grey;">(</span><span style="color: black;">yy</span><span style="color: grey;">,</span><span style="color: black;">0</span><span style="color: grey;">,</span><span style="color: magenta;">GETDATE</span><span style="color: grey;">()),</span><span style="color: black;">0</span><span style="color: grey;">))</span> <span style="color: red;">'First Day of Last Year'</span><span style="color: green;"> </span></code></span></span><br />
<span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"><code style="font-size: 12px;"><span style="color: green;">----Last Day of Last Year</span><span style="color: blue;">SELECT</span> <span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">ms</span><span style="color: grey;">,-</span><span style="color: black;">3</span><span style="color: grey;">,</span><span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">yy</span><span style="color: grey;">,</span><span style="color: black;">0</span><span style="color: grey;">,</span><span style="color: magenta;">DATEADD</span><span style="color: grey;">(</span><span style="color: black;">yy</span><span style="color: grey;">,</span><span style="color: magenta;">DATEDIFF</span><span style="color: grey;">(</span><span style="color: black;">yy</span><span style="color: grey;">,</span><span style="color: black;">0</span><span style="color: grey;">,</span><span style="color: magenta;">GETDATE</span><span style="color: grey;">()),</span><span style="color: black;">0</span><span style="color: grey;">)))</span> <span style="color: red;">'Last Day of Last Year'</span></code></span></span></div>
</div>
</div>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7591391552778927829.post-28158351381801638552012-06-19T09:47:00.003-07:002012-06-19T09:47:58.514-07:00How to display alert message from javascript inside the ASPXCallbackPanel<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<pre><span style="border-collapse: separate; color: black; font-family: Tahoma; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><code><span style="font-family: Tahoma;">protected void OnCallback(object source, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e) </span></code></span></pre>
<pre><span style="border-collapse: separate; color: black; font-family: Tahoma; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><code><span style="font-family: Tahoma;"><span>{</span> </span></code></span></pre>
<pre><code><span style="font-family: Tahoma;"><span> ASPxCallbackPanel</span> <span>callbackPanel</span> <span>=</span> <span>(</span><span>ASPxCallbackPanel</span><span>)</span><span>source</span><span>;</span> </span></code></pre>
<pre><code><span style="font-family: Tahoma;"><span> callbackPanel</span><span>.</span><span>Controls</span><span>.</span><span>Add</span><span>(</span><span>new</span> <span>LiteralControl</span><span>(</span><span>"My New Content"</span><span>)</span><span>)</span><span>;</span> </span></code></pre>
<pre><code><span style="font-family: Tahoma;"><span> WebControl</span> <span>script</span> <span>=</span> <span>new</span> <span>WebControl</span><span>(</span><span>HtmlTextWriterTag</span><span>.</span><span>Script</span><span>)</span><span>;</span> </span></code></pre>
<pre><code><span style="font-family: Tahoma;"><span> callbackPanel</span><span>.</span><span>Controls</span><span>.</span><span>Add</span><span>(</span><span>script</span><span>)</span><span>;</span> </span></code></pre>
<pre><code><span style="font-family: Tahoma;"><span> script</span><span>.</span><span>Attributes</span><span>[</span><span>"id"</span><span>]</span> <span>=</span> <span>"dxss_123456"</span><span>;</span> </span></code></pre>
<pre><code><span style="font-family: Tahoma;"><span> script</span><span>.</span><span>Attributes</span><span>[</span><span>"type"</span><span>]</span> <span>=</span> <span>"text/javascript"</span><span>;</span> </span></code></pre>
<pre><code><span style="font-family: Tahoma;"><span> script</span><span>.</span><span>Controls</span><span>.</span><span>Add</span><span>(</span><span>new</span> <span>LiteralControl</span><span>(</span><span>"var str = 'test'; alert(str);"</span><span>)</span><span>)</span><span>;</span> </span></code></pre>
<pre><code><span style="font-family: Tahoma;">}</span></code></pre>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7591391552778927829.post-76584109897018868182012-06-19T09:46:00.003-07:002012-06-19T09:46:37.003-07:00City, State and Country usingcascading dropdownlist(through Webservice)<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div>
<span style="border-collapse: separate; color: black; font-family: Tahoma; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">ASP.Net Page:</span></div>
<div align="left">
<span style="border-collapse: separate; color: black; font-family: Tahoma; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-size: 9pt;"><%</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">@</span></span><span> </span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Register</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Assembly</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="AjaxControlToolkit"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Namespace</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="AjaxControlToolkit"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">TagPrefix</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="asp"</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-size: 9pt;">%></span></span></span></div>
<div>
<b>Country:</b></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">asp</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">:</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">DropDownList</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">ID</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="ddlCountry"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CssClass</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="ddlist"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Width</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="202"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">runat</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="server"></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"></</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">asp</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">:</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">DropDownList</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">asp</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">:</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CascadingDropDown</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">ID</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="CountryCascading"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">runat</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="server"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Category</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="Country"</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">TargetControlID</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="ddlCountry"</span></span></div>
<div align="left">
<span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">PromptText</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="Select Country"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">ServiceMethod</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="BindCountrydropdown"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">LoadingText</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="Loading Countries..."</span></span></div>
<div align="left">
<span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">ServicePath</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="~/Assets/DropdownWebService.asmx"></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"></</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">asp</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">:</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CascadingDropDown</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">></span></span></div>
<div>
<b>State:</b></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">asp</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">:</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">DropDownList</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">ID</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="ddlState"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CssClass</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="ddlist"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Width</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="202"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">runat</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="server"></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"></</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">asp</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">:</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">DropDownList</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">asp</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">:</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CascadingDropDown</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">ID</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="StateCascading"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">runat</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="server"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Category</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="State"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">TargetControlID</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="ddlState"</span></span></div>
<div align="left">
<span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">ParentControlID</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="ddlCountry"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">LoadingText</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="Loading States..."</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">PromptText</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="Select State"</span></span></div>
<div align="left">
<span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">ServiceMethod</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="BindStatedropdown"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">ServicePath</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="~/Assets/DropdownWebService.asmx"></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"></</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">asp</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">:</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CascadingDropDown</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">></span></span></div>
<div>
<b>City:</b></div>
<div align="left" style="text-align: left;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">asp</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">:</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">DropDownList</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">ID</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="ddlCity"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CssClass</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="ddlist"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Width</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="202"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">runat</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="server"></span></span></div>
<div align="left" style="text-align: left;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"></</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">asp</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">:</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">DropDownList</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">></span></span></div>
<div align="left" style="text-align: left;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">asp</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">:</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CascadingDropDown</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">ID</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="RegionCascading"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">runat</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="server"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Category</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="Region"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">TargetControlID</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="ddlCity"</span></span></div>
<div align="left" style="text-align: left;">
<span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">ParentControlID</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="ddlState"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">LoadingText</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="Loading Cities..."</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">PromptText</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="Select City"</span></span></div>
<div align="left" style="text-align: left;">
<span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">ServiceMethod</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="BindRegiondropdown"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">ServicePath</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="~/Assets/DropdownWebService.asmx"></span></span></div>
<div align="left" style="text-align: left;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"></</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">asp</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">:</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CascadingDropDown</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">></span></span></div>
<div align="left" style="text-align: left;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><br /></span></span></div>
<div align="left" style="font-size: 14px; text-align: left;">
<span style="font-size: xx-small;"><span style="font-size: 13px;"><b>.CS File</b></span></span></div>
<div align="left" style="font-size: 14px; text-align: left;">
<span style="font-size: xx-small;"><span style="font-size: 13px;"><b><br /></b></span></span></div>
<div align="left" style="font-size: 14px; text-align: left;">
<div align="left">
<span style="font-size: xx-small;"><span style="font-size: 13px;"><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">if</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">(</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Convert</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">.ToInt32(objCompanyDT.Rows[0][</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"CountryID"</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">])!=0)</span></span></span></span></div>
<div align="left">
<span style="font-size: xx-small;"><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">{</span></span></span></div>
<div align="left">
<span style="font-size: xx-small;"><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> CountryCascading.SelectedValue = objCompanyDT.Rows[0][</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"CountryID"</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">].ToString();</span></span></span></div>
<div align="left">
<span style="font-size: xx-small;"><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">}</span></span></span></div>
<div align="left">
<span style="font-size: xx-small;"><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="left">
<div align="left">
<span style="font-size: xx-small;"><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">if</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">(ddlCountry.SelectedItem.Text !=</span></span><span> </span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"Select Country"</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">&& ddlCountry.SelectedItem.Text !=</span></span><span> </span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">""</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">)</span></span></span></span></span></div>
<div align="left">
<span style="font-size: xx-small;"><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">{</span></span></span></span></div>
<div align="left">
<span style="font-size: xx-small;"><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> objCompany.Country = ddlCountry.SelectedItem.Value;</span></span></span></span></div>
<div align="left">
<span style="font-size: xx-small;"><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">}</span></span></span></span></div>
</div>
</div>
<div align="left" style="text-align: left;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><br /></span></span></div>
<div align="left" style="font-size: 14px; text-align: left;">
<span style="font-size: xx-small;"><span style="font-size: 13px;"><b>In Web Service<span> </span><a href="">File:</a></b></span></span></div>
<div align="left" style="font-size: 14px; text-align: left;">
<span style="font-size: xx-small;"><span style="font-size: 13px;"><br /></span></span></div>
<div align="left" style="text-align: left;">
<div align="left" style="font-size: 13px;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">using</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">System;</span></span></div>
<div align="left" style="font-size: 13px;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">using</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">System.Collections;</span></span></div>
<div align="left" style="font-size: 13px;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">using</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">System.Web;</span></span></div>
<div align="left" style="font-size: 13px;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">using</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">System.Web.Services;</span></span></div>
<div align="left" style="font-size: 13px;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">using</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">System.Web.Services.Protocols;</span></span></div>
<div align="left" style="font-size: 13px;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">using</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">System.Data.SqlClient;</span></span></div>
<div align="left" style="font-size: 13px;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">using</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">System.Collections.Generic;</span></span></div>
<div align="left" style="font-size: 13px;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">using</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">System.Collections.Specialized;</span></span></div>
<div align="left" style="font-size: 13px;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">using</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">AjaxControlToolkit;</span></span></div>
<div align="left" style="font-size: 13px;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">using</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">System.Configuration;</span></span></div>
<div align="left" style="font-size: 13px;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">using</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">System.Data;</span></span></div>
<div align="left" style="font-size: 13px;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">using</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">IUSCRMLib.DataManagers;</span></span></div>
<div align="left">
<div align="left" style="font-size: 13px;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">namespace</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">IUSCRM.Assets</span></span></div>
<div align="left" style="font-size: 13px;">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">{</span></span></div>
</div>
<span style="font-size: 13px;"><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">[</span></span></span><span style="font-size: 13px;"><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">WebService</span></span></span><span style="font-size: 13px;"><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">(Namespace =</span></span></span><span> </span><span style="font-size: 13px;"><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"http://tempuri.org/"</span></span></span><span style="font-size: 13px;"><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">)]</span></span></span></div>
<div align="left" style="text-align: left;">
<span style="font-size: 13px;"><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">[</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">WebServiceBinding</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">(ConformsTo =</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">WsiProfiles</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">.BasicProfile1_1)]</span></span></span><div align="left">
<div align="left" style="font-size: 13px;">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">[System.ComponentModel.</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">ToolboxItem</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">(</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">false</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">)]</span></span></div>
<div align="left" style="font-size: 13px;">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">[System.Web.Script.Services.</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">ScriptService</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">()]</span></span></div>
<div align="left">
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">public</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">class</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">DropdownWebService</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">: System.Web.Services.</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">WebService</span></span></span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">{</span></span></span></div>
</div>
</div>
<span style="font-size: 13px;"><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">[</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">WebMethod</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">]</span></span></span><div align="left">
<div align="left">
<div align="left" style="font-size: 13px;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">public</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CascadingDropDownNameValue</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">[] BindCountrydropdown(</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">string</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">knownCategoryValues,</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">string</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">category)</span></span></div>
<div align="left" style="font-size: 13px;">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">{</span></span></div>
</div>
</div>
<span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> SqlConnection</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">concountry = IUSCRMLib.</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">SqlHelper</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">.GetDBConnetion();</span></span><div align="left">
<div align="left">
<div align="left">
<span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> SqlCommand</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">cmdcountry =</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">new</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">SqlCommand</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">(</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"select * from Countries where IsActive=1"</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">, concountry);</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> S</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">qlDataAdapter</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">dacountry =</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">new</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">SqlDataAdapter</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">(cmdcountry);</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> cmdcountry.ExecuteNonQuery();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">DataSet</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">dscountry =</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">new</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">DataSet</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> dacountry.Fill(dscountry);</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">List</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CascadingDropDownNameValue</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">> countrydetails =</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">new</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">List</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CascadingDropDownNameValue</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">>();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">foreach</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">(</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">DataRow</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">dtrow</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">in</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">dscountry.Tables[0].Rows)</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> {</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">string</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CountryID = dtrow[</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"CountryId"</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">].ToString();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">string</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CountryName = dtrow[</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"Country"</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">].ToString();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> countrydetails.Add(</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">new</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CascadingDropDownNameValue</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">(CountryName, CountryID));</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> }</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">return</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">countrydetails.ToArray();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> }</span></span></div>
</div>
</div>
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">[</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">WebMethod</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">]</span></span></div>
<div align="left" style="text-align: left;">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">public</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CascadingDropDownNameValue</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">[] BindStatedropdown(</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">string</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">knownCategoryValues,</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">string</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">category)</span></span><div align="left">
<div align="left">
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">{</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">int</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CountryID;</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">StringDictionary</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">countrydetails = AjaxControlToolkit.</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CascadingDropDown</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">.ParseKnownCategoryValuesString(knownCategoryValues);</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> CountryID =</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Convert</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">.ToInt32(countrydetails[</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"Country"</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">]);</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">SqlConnection</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">constate = IUSCRMLib.</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">SqlHelper</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">.GetDBConnetion();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">SqlCommand</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">cmdstate =</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">new</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">SqlCommand</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">(</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"select * from State where CountryID=@CountryID and State <> (select Country from Countries where CountryId=@CountryID) and IsActive=1"</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">, constate);</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> cmdstate.Parameters.AddWithValue(</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"@CountryID"</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">, CountryID);</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> cmdstate.ExecuteNonQuery();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">SqlDataAdapter</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">dastate =</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">new</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">SqlDataAdapter</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">(cmdstate);</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">DataSet</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">dsstate =</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">new</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">DataSet</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> dastate.Fill(dsstate);</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">List</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CascadingDropDownNameValue</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">> statedetails =</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">new</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">List</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CascadingDropDownNameValue</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">>();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">foreach</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">(</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">DataRow</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">dtstaterow</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">in</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">dsstate.Tables[0].Rows)</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> {</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">string</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">stateID = dtstaterow[</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"StateID"</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">].ToString();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">string</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">statename = dtstaterow[</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"State"</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">].ToString();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> statedetails.Add(</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">new</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CascadingDropDownNameValue</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">(statename, stateID));</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> }</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">return</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">statedetails.ToArray();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">}</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">[</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">WebMethod</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">]</span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">public</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CascadingDropDownNameValue</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">[] BindRegiondropdown(</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">string</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">knownCategoryValues,</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">string</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> category)</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">{</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">int</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">stateID;</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">StringDictionary</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">statedetails = AjaxControlToolkit.</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CascadingDropDown</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">.ParseKnownCategoryValuesString(knownCategoryValues);</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> stateID =</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Convert</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">.ToInt32(statedetails[</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"State"</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">]);</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">SqlConnection</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">conregion = IUSCRMLib.</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">SqlHelper</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">.GetDBConnetion();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">SqlCommand</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">cmdregion =</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">new</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">SqlCommand</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">(</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"Select * from Cities where StateID=@StateID and City <> (select state from state where StateID=@StateID) and IsActive=1 "</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">, conregion);</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> cmdregion.Parameters.AddWithValue(</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"@StateID"</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">, stateID);</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> cmdregion.ExecuteNonQuery();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">SqlDataAdapter</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">daregion =</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">new</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">SqlDataAdapter</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">(cmdregion);</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">DataSet</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">dsregion =</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">new</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">DataSet</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> daregion.Fill(dsregion);</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">List</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CascadingDropDownNameValue</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">> regiondetails =</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">new</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">List</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CascadingDropDownNameValue</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">>();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">foreach</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">(</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">DataRow</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">dtregionrow</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">in</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">dsregion.Tables[0].Rows)</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> {</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">string</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">regionID = dtregionrow[</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"CityId"</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">].ToString();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">string</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">regionname = dtregionrow[</span></span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"City"</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">].ToString();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> regiondetails.Add(</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">new</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">CascadingDropDownNameValue</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">(regionname, regionID));</span></span></div>
</div>
</div>
<span style="color: #010101; font-family: Consolas; font-size: 12px;"> }</span><div align="left">
<div align="left">
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">return</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">regiondetails.ToArray();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">}</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">}</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">}</span></span></div>
</div>
</div>
</div>
</div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-7591391552778927829.post-33264553559553925552012-06-19T09:45:00.004-07:002012-06-19T09:45:51.534-07:00How to GetTime Zones in C#<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="border-collapse: separate; color: black; font-family: Tahoma; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="color: #147191;"><b>Getting Time Zone:</b></span></span><br />
<div>
<span style="border-collapse: separate; color: black; font-family: Tahoma; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="color: #147191;"><b><br /></b></span></span></div>
<div align="left">
<span style="border-collapse: separate; color: black; font-family: Tahoma; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="color: #147191;"><b><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">if</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">(!IsPostBack)</span></span></b></span></span></div>
<div align="left">
<span style="color: #147191;"><b><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">{</span></span></b></span></div>
<div align="left">
<span style="color: #147191;"><b><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> drpDwnTimeZone.DataSource = GetTimeZones();</span></span></b></span></div>
<div align="left">
<span style="color: #147191;"><b><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> drpDwnTimeZone.DataTextField =</span></span><span> </span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"Name"</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">;</span></span></b></span></div>
<div align="left">
<span style="color: #147191;"><b><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> drpDwnTimeZone.DataValueField =</span></span><span> </span><span style="color: #a31515; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"ID"</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">;</span></span></b></span></div>
<div align="left">
<span style="color: #147191;"><b><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> drpDwnTimeZone.DataBind();</span></span></b></span></div>
<div align="left">
<span style="color: #147191;"><b><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> ShowCustomerProfile();</span></span></b></span></div>
<div align="left">
<span style="color: #147191;"><b><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">}</span></span></b></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">public</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Collection</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">MyStruct</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">> GetTimeZones()</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">{</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">var</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">myClass =</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">new</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Collection</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><</span></span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">MyStruct</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">>();</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">foreach</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">(</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">var</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">timeZoneInfo</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">in</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">TimeZoneInfo</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">.GetSystemTimeZones())</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> {</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> myClass.Add(</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">new</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">MyStruct</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">{ Name = timeZoneInfo.DisplayName, ID = timeZoneInfo.Id });</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> }</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">return</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">myClass;</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">}</span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">public</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">struct</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">MyStruct</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">{</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">public</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">string</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Name {</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">get</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">;</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">set</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">; }</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">public</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">string</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">ID {</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">get</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">;</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">set</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">; }</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">} </span></span></div>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7591391552778927829.post-88024968965360407862012-06-19T09:45:00.001-07:002012-06-19T09:45:13.307-07:00Getting last inserted Table primary key ID value in SQL Server(Through query)<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div align="left" style="color: #147191;">
<span style="border-collapse: separate; color: black; font-family: Tahoma; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">declare</span></span><span> </span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">@ID</span></span><span> </span><span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">int</span></span></span></div>
<div align="left" style="color: #147191;">
<span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">if</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">select</span></span><span> </span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">last_value</span></span><span> </span><span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">from</span></span><span> </span><span style="color: green; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">sys</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">.</span></span><span style="color: green; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">identity_columns</span></span><span> </span><span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">where</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"> [object_id]</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">=</span></span><span style="color: magenta; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">object_id</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">'YourTableName'</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">))</span></span><span> </span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">is</span></span><span> </span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">null</span></span></div>
<div align="left">
<span style="color: #2d4fc9; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">begin</span></span></div>
<div align="left" style="color: #147191;">
<span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"> </span></span><span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">set</span></span><span> </span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">@ID</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">=</span></span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">0</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">;</span></span></div>
<div align="left" style="color: #147191;">
<span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"> </span></span><span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">select</span></span><span> </span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">@ID</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">;</span></span></div>
<div align="left">
<span style="color: #2d4fc9; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">end</span></span></div>
<div align="left" style="color: #147191;">
<span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">else</span></span></div>
<div align="left" style="color: #147191;">
<span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">begin</span></span></div>
<div align="left" style="color: #147191;">
<span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;"> </span></span><span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">select</span></span><span> </span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">last_value</span></span><span> </span><span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">from</span></span><span> </span><span style="color: green; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">sys</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">.</span></span><span style="color: green; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">identity_columns</span></span><span> </span><span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">where</span></span><span> </span><span style="color: #010101; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">[object_id]</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">=</span></span><span style="color: magenta; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">object_id</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">(</span></span><span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">'</span></span><span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">YourTableName</span></span><span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">'</span></span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">)</span></span></div>
<div align="left" style="color: #147191;">
<span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">en</span></span></div>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7591391552778927829.post-88698828810458188602012-06-19T09:43:00.002-07:002012-06-19T09:43:22.678-07:00How To Take SQL Backup through SQL Query<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<h3 style="text-align: left;">
<span style="border-collapse: separate; color: black; font-family: Tahoma; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><b><span style="color: #147191;"><span style="border-collapse: separate; color: black; font-family: Tahoma; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="text-align: -webkit-left;"><span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">backup</span></span><span> </span><span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">database</span></span><span> mydatabasename </span><span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">to</span></span><span> </span><span style="color: blue; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">disk</span></span><span> </span><span style="color: grey; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">=</span></span><span> </span><span style="color: red; font-family: Courier New; font-size: x-small;"><span style="font-size: 10pt;">'c:\backup\mybackupfilename.bak'</span></span></span></span></span></b></span></h3>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7591391552778927829.post-8723274235922528652012-06-19T09:41:00.002-07:002012-06-19T09:41:24.367-07:00SQL GROUP BY techniques<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="font-size: 15px;">
<span style="border-collapse: separate; color: black; font-family: Tahoma; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="font-family: 'Courier New';"><span style="font-family: 'Courier New';"><span style="color: #147191;"><b>Normal Technique:</b></span></span></span></span></div>
<div>
<span style="font-family: 'Courier New';"><br /></span></div>
<div>
<span style="font-family: 'Courier New';"><span style="font-family: 'Courier New';">SELECT</span><br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New';"> C.CustomerID, C.CustomerName, </span><br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New';"> C.CustomerType, C.Address1, C.City,</span><br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New';"> C.State, SUM(S.Sales) as TotalSales</span><br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New';">FROM</span><br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New';"> Customers C</span><br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New';">INNER JOIN Sales S</span><br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New';"> ON C.CustomerID = S.CustomerID</span><br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New'; font-weight: bold;">GROUP BY</span><br style="font-family: 'Courier New'; font-weight: bold;" /><span style="font-family: 'Courier New'; font-weight: bold;"> C.CustomerID, C.CustomerName,</span><br style="font-family: 'Courier New'; font-weight: bold;" /><span style="font-family: 'Courier New'; font-weight: bold;"> C.CustomerType, C.Address1, C.City, C.State</span></span></div>
<div>
<span style="font-family: 'Courier New';"><br /></span></div>
<div style="font-size: 15px;">
<span style="font-family: 'Courier New';"><span style="color: #147191;"><b>Advanced Technique:</b></span></span></div>
<div>
<span style="font-family: 'Courier New';"><br /></span></div>
SELECT<br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New';"> C.CustomerID, C.CustomerName,</span><br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New';"> C.CustomerType, C.Address1, C.City,</span><br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New';"> C.State, S.TotalSales</span><br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New';">FROM</span><br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New';"> Customers C</span><br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New';">INNER JOIN</span><br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New';"> (SELECT</span><br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New';"> CustomerID, SUM(Sales) as TotalSales</span><br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New';"> FROM</span><br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New';"> Sales</span><br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New';"> <span> </span><span style="font-weight: bold;">GROUP BY</span></span><br style="font-family: 'Courier New'; font-weight: bold;" /><span style="font-family: 'Courier New';"><span style="font-weight: bold;"> CustomerID</span>) S</span><br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New';">ON</span><br style="font-family: 'Courier New';" /><span style="font-family: 'Courier New';"> C.CustomerID = S.CustomerID</span>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7591391552778927829.post-75575679760238324672012-06-19T09:39:00.001-07:002012-06-19T09:39:18.181-07:00How to use ajax(Page Method) by using jquery<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div align="left" style="font-size: 21px;">
<span style="border-collapse: separate; color: black; font-family: Tahoma; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><b><span style="color: #010101; font-family: Consolas;">How to use ajax(Page Method) by using jquery </span><span style="color: blue; font-family: Consolas;"> </span></b></span></div>
<div align="left">
<span style="border-collapse: separate; color: black; font-family: Tahoma; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="left">
<span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">script</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">type</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="text/javascript"></span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">function</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">ChangeStatusOrder(ID, action,confirmationType ) {</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> $.ajax({</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> type:</span></span><span> </span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"POST"</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">,</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> url:</span></span><span> </span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"TransactionStatusMaster.aspx/UpdateCurrentOrder"</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">,</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> data:</span></span><span> </span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"{id:"</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">+ ID +</span></span><span> </span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">",action:"</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">+ action +</span></span><span> </span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">",confirmation:'"</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">+ </span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">confirmationType </span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> +</span></span><span> </span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"'}"</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">,</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> contentType:</span></span><span> </span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"application/json; charset=utf-8"</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">,</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> dataType:</span></span><span> </span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">"json"</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">,</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> success:</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">function</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">(msg) {</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span> </span><span style="color: darkgreen; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">// Do something interesting here.</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> }</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> });</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><br /></span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><br /></span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> }</span></span></div>
<div align="left">
</div>
<div>
<br /></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"></</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">script</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">></span></span></div>
<div align="left">
<span style="font-size: small;"> </span></div>
<div align="left" style="color: #444444;">
<span style="font-size: small;"><b> <span style="font-family: Consolas;"><span>TransactionStatusMaster.aspx</span></span></b></span></div>
<div align="left">
<span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><span style="font-size: small;"><b><span style="color: black;"><span style="color: #444444;">==============================</span> </span></b></span></span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><</span></span><span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">img</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">src</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="../../Assets/Images/arrow_up.png"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">onclick</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="ChangeStatusOrder(</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-size: 9pt;"><%</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">#</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Eval("ID")</span><span> </span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-size: 9pt;">%></span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">,0,'</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-size: 9pt;"><%</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">#</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">Eval("ASGroup")</span><span> </span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-size: 9pt;">%></span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">')"</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">alt</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="Move Up"</span></span><span> </span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">style</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">="</span></span><span style="color: red; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">cursor</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">: pointer;"</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">/></span></span></div>
<div>
<b><br /></b></div>
<div style="color: black;">
<b><span style="font-family: Consolas; font-size: small;"><span>TransactionStatusMaster.aspx.cs:</span></span></b></div>
<div>
<span style="color: maroon; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"><b><span style="color: black; font-size: small;">================================ </span></b></span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> [System.Web.Services.</span></span><span> </span><span style="color: #2b91af; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">WebMethod</span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">]</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">public</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">static</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">string</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">UpdateCurrentOrder(</span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">int</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">id,</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">int</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">action,</span></span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">string</span></span><span> </span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">confirmation)</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> {</span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span></div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">//perform your action here</span></span></div>
<div align="left">
<h2 style="text-align: left;">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> </span></span><span> </span><span style="color: blue; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;">return</span></span><span> <span style="color: #010101; font-size: x-small;"><span style="font-family: Consolas;">"your success message"</span></span></span><span style="color: #010101; font-family: Consolas; font-size: x-small;"><span>;</span></span></h2>
</div>
<div align="left">
<span style="color: #010101; font-family: Consolas; font-size: xx-small;"><span style="font-size: 9pt;"> }</span></span></div>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7591391552778927829.post-90242102977815211992012-06-19T09:34:00.000-07:002012-06-19T09:34:22.082-07:00Send Email From SQL Server<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
Today in this article I would discuss
about the Database Mail which is used to send the Email using SQL
Server. Previously I had discussed about <strong><a href="http://www.google.co.in/url?sa=t&ct=res&cd=1&url=http%3A%2F%2Fblog.sqlauthority.com%2F2008%2F07%2F05%2Fsql-server-difference-between-database-mail-and-sqlmail%2F&ei=22CuSMeBF4ii8ATlqZGMAQ&usg=AFQjCNHw0-zYejUdtVp3A00UuwTnHN63sg&sig2=IF8Q0qevrEm2WdwxBmRR-Q" target="_blank">SQL SERVER – Difference Between Database Mail and SQLMail</a>.</strong>
Database mail is the replacement of the SQLMail with many enhancements.
So one should stop using the SQL Mail and upgrade to the Database Mail.
Special thanks to <em>Software Developer <strong>Monica</strong>, </em>who helped with all the images and extensive testing of subject matter of this article.</div>
<div style="text-align: justify;">
In order to send mail using Database Mail
in SQL Server, there are 3 basic steps that need to be carried out. 1)
Create Profile and Account 2) Configure Email 3) Send Email.</div>
<div style="text-align: justify;">
<strong>Step 1) Create Profile and Account:</strong></div>
<div style="text-align: justify;">
You need to create a profile and account
using the Configure Database Mail Wizard which can be accessed from the
Configure Database Mail context menu of the Database Mail node in
Management Node. This wizard is used to manage accounts, profiles, and
Database Mail global settings which are shown below:</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.pinaldave.com/bimg/dbmail/step-2%20openWizard.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="280" src="http://www.pinaldave.com/bimg/dbmail/step-2%20openWizard.gif" width="320" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<img alt="" class="alignnone" height="437" src="http://www.pinaldave.com/bimg/dbmail/step-4%20CreateProfile.gif" width="500" /></div>
<div style="text-align: justify;">
<img alt="" class="alignnone" height="435" src="http://www.pinaldave.com/bimg/dbmail/step-5%20CreateProfile2.gif" width="500" /></div>
<div style="text-align: justify;">
<img alt="" class="alignnone" height="435" src="http://www.pinaldave.com/bimg/dbmail/step-6%20AddAccount.gif" width="500" /></div>
<div style="text-align: justify;">
<img alt="" class="alignnone" height="435" src="http://www.pinaldave.com/bimg/dbmail/step-7%20SMTPAccounts.gif" width="500" /></div>
<div style="text-align: justify;">
<img alt="" class="alignnone" height="435" src="http://www.pinaldave.com/bimg/dbmail/step-8%20Manage.gif" width="500" /></div>
<div style="text-align: justify;">
<img alt="" class="alignnone" height="435" src="http://www.pinaldave.com/bimg/dbmail/step-9%20Parameters.gif" width="500" /></div>
<div style="text-align: justify;">
<img alt="" class="alignnone" height="435" src="http://www.pinaldave.com/bimg/dbmail/step-10%20Complete.gif" width="500" /></div>
<div style="text-align: justify;">
<img alt="" class="alignnone" height="435" src="http://www.pinaldave.com/bimg/dbmail/step-11%20Success.gif" width="500" /></div>
<div style="text-align: justify;">
<strong>Step 2) Configure Email:</strong></div>
<div style="text-align: justify;">
After the Account and the Profile are
created successfully, we need to configure the Database Mail. To
configure it, we need to enable the Database Mail XPs parameter through
the sp_configure stored procedure, as shown here:</div>
<div style="text-align: justify;">
<code style="font-size: 12px;"><span style="color: darkred;">sp_CONFIGURE </span><span style="color: red;">'show advanced'</span><span style="color: grey;">, </span><span style="color: black;">1<br />
GO<br />
</span><span style="color: blue;">RECONFIGURE<br />
</span><span style="color: black;">GO<br />
</span><span style="color: darkred;">sp_CONFIGURE </span><span style="color: red;">'Database Mail XPs'</span><span style="color: grey;">, </span><span style="color: black;">1<br />
GO<br />
</span><span style="color: blue;">RECONFIGURE<br />
</span><span style="color: black;">GO</span></code>
</div>
<div style="text-align: justify;">
<img alt="" class="alignnone" height="234" src="http://www.pinaldave.com/bimg/dbmail/ConfigQuery.gif" width="500" /></div>
<div style="text-align: justify;">
<strong>Step 3) Send Email:</strong></div>
<div style="text-align: justify;">
After all configurations are done, we are
now ready to send an email. To send mail, we need to execute a stored
procedure sp_send_dbmail and provide the required parameters as shown
below:</div>
<div style="text-align: justify;">
<code style="font-size: 12px;"><span style="color: blue;">USE </span><span style="color: black;">msdb<br />
GO<br />
</span><span style="color: blue;">EXEC </span><span style="color: darkred;">sp_send_dbmail </span><span style="color: #434343;">@profile_name</span><span style="color: blue;">=</span><span style="color: red;">'PinalProfile'</span><span style="color: grey;">,<br />
</span><span style="color: #434343;">@recipients</span><span style="color: blue;">=</span><span style="color: red;">'test@Example.com'</span><span style="color: grey;">,<br />
</span><span style="color: #434343;">@subject</span><span style="color: blue;">=</span><span style="color: red;">'Test message'</span><span style="color: grey;">,<br />
</span><span style="color: #434343;">@body</span><span style="color: blue;">=</span><span style="color: red;">'This is the body of the test message.<br />
Congrates Database Mail Received By you Successfully.'</span></code>
</div>
<div style="text-align: justify;">
<img alt="" class="alignnone" height="341" src="http://www.pinaldave.com/bimg/dbmail/SendQuery.gif" width="500" /></div>
<div style="text-align: justify;">
After all validations of the parameters
entered are done, certain stored procedures are executed and the mail is
queued by Service Broker, read more at <a href="http://blog.sqlauthority.com/2008/07/18/sql-server-introduction-to-service-broker/" target="_blank">SQL SERVER – Introduction to Service Broker</a>.</div>
<div style="text-align: justify;">
Database Mail keeps copies of outgoing e-mail messages and displays them in the <strong>sysmail_allitems,</strong><strong> sysmail_sentitems</strong>, <strong>sysmail_unsentitems</strong>, <strong>sysmail_faileditems</strong> <strong>.</strong> The status of the mail sent can be seen in <strong>sysmail_mailitems</strong>
table, when the mail is sent successfully the sent_status field of the
sysmail_mailitems table is set to 1 which can again be seen in
sysmail_sentitems table. The mails that are failed will have the
sent_status field value to 2 and those are unsent will have value 3.<br />
The log can be checked in <strong>sysmail_log</strong> table as shown below:</div>
<div style="text-align: justify;">
<code style="font-size: 12px;"><span style="color: blue;">SELECT </span><span style="color: grey;">*<br />
</span><span style="color: blue;">FROM </span><span style="color: black;">sysmail_mailitems<br />
GO<br />
</span><span style="color: blue;">SELECT </span><span style="color: grey;">*<br />
</span><span style="color: blue;">FROM </span><span style="color: black;">sysmail_log<br />
GO</span></code>
</div>
<div style="text-align: justify;">
<img alt="" class="alignnone" height="390" src="http://www.pinaldave.com/bimg/dbmail/MailLog.gif" width="500" /></div>
<div style="text-align: justify;">
Status can be verified using sysmail_sentitems table.</div>
<div style="text-align: justify;">
<img alt="" class="alignnone" height="418" src="http://www.pinaldave.com/bimg/dbmail/sent_status.gif" width="500" /></div>
<div style="text-align: justify;">
After sending mail you can check the mail received in your inbox, just as I received as shown below.</div>
<div style="text-align: justify;">
<img alt="" class="alignnone" height="147" src="http://www.pinaldave.com/bimg/dbmail/DBMailSent.gif" width="566" /></div>
<br />
Source:<a href="http://blog.sqlauthority.com/2008/08/23/sql-server-2008-configure-database-mail-send-email-from-sql-database/" target="_blank"> sqlauthority.com</a></div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-7591391552778927829.post-37354999674110006512012-06-19T09:30:00.003-07:002012-06-19T09:30:38.414-07:00SQL basics<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="border-collapse: separate; color: black; font-family: Tahoma; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">Create New Database:<br />
===================<br /><br />
1. right click on "Databases" folder and click on "Create new Database" then it will shows dialog then enter database name and then click ok<br />
after clicking ok new database created with the given database name under databases<br /><br />
Creating Table:<br />
===============<br />
2. expand your database and right click on tables and click on "New Table" then give your columns with appropriate datatype and save table with your table name click on ok. Now new table created under the tables with the given table name<br /><br />
Selecting Data:<br />
==============<br />
3. Select * from tablename<br /><br />
Inserting Data:<br />
==============<br />
<br />
4. Inserting values into the existing table<br /><br />
Insert into tablename(column1,column1) values(1,'test');<br />
<br />
result: 1 row(s) inserted sucessfully<br /><br />
Updating Data:<br />
==============<br />
<br />
4. Updating existing table data<br /><br />
Update tablename SET column2='testt' where column1=2<br />
<br />
result: 1 row(s) Updated sucessfully<br /><br /><br />
Delete Data:<br />
==============<br />
<br />
4.deleting existing table data<br />
<br />
delete from tablename where column1=2</span>
</div>Unknownnoreply@blogger.com0