March 8, 2007
March 6, 2007
Crystal – Streaming a report to the browser (PDF)
/// <summary>
/// Exports a crystal report to PDF.
/// </summary>
/// <param name=”wrpi”></param>
/// <param name=”myReportDocument”></param>
public static void ExportToPDF(System.Web.HttpResponse responseObj, CrystalDecisions.CrystalReports.Engine.ReportDocument myReportDocument)
{
System.IO.MemoryStream oStream = (System.IO.MemoryStream)myReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
responseObj.Clear();
responseObj.Buffer = true;
responseObj.ContentType = “application/pdf”;
try
{
responseObj.BinaryWrite(oStream.ToArray());
responseObj.End();
}
catch
{
}
}
Vista – Debugging with Visual Studio 2005
Steps that I had to make in order to get this to work.
1. Install IIS 7
2. (64 bit) Install “Visual Studio 2005 Remote Debugger
DVD\vs\Remote Debugger\x64
3. Switched from the DefaultAppPool to ”Classic .NET AppPool” in Advanced Settings
March 5, 2007
Home – Wiring up a ceiling fan
How do I wire up a ceiling fan? That was the very question I faced after moving into my new home. What are all those various colors for? So if this is helpful to anyone, and if you have the same wiring, here you go.
House: Red Fan: Black & White – Only use if separate switch in house for fan and lights [Do Not Use if 1 switch]
House: Black Fan: Black (And Black/White if 1 switch controlls both) – Fan
House: Green (Or bare copper) Fan: Green (Ground)
House: White Fan: White (Neutral)
House: Brown Not Used
.NET – Allowing dynamic controls with viewstate
<asp:PlaceHolder runat=”server” ID=”panel1″>
</asp:PlaceHolder>
<asp:Button id=”Button1″ runat=”server” Text=”Submit”></asp:Button>
********************************
Partial Class Default2
Inherits System.Web.UI.Page
‘ Added by hand; will create instance in OnInit.
Public TextBox1 As System.Web.UI.WebControls.TextBox
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
‘ Create dynamic controls here.
TextBox1 = New TextBox()
panel1.Controls.Add(TextBox1)
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
‘ Set the initial properties for the text boxes.
TextBox1.Text = “TextBox1″
End If
End Sub
End Class
SQL Server 2005 – Execute Role
/* CREATE A NEW ROLE */
CREATE ROLE db_executor
/* GRANT EXECUTE TO THE ROLE */
GRANT EXECUTE TO db_executor
XPath – Tutorial
<?xml version=”1.0″ encoding=”ISO-8859-1″?><bookstore><book>
<title lang=”eng”>Harry Potter</title>
<price>29.99</price>
</book><book>
<title lang=”eng”>Learning XML</title>
<price>39.95</price>
</book></bookstore>
********************************
/ – Selects from the root node
// – Selects nodes in the document from the current node that match the selection no matter where they are
. – Selects the current node
.. – Selects the parent of the current node
@ – Selects attributes
——————————————————————————–
Path Expression Result
/bookstore/book[1] Selects the first book element that is the child of the bookstore element
/bookstore/book[last()] Selects the last book element that is the child of the bookstore element
/bookstore/book[last()-1] Selects the last but one book element that is the child of the bookstore element
/bookstore/book[position()<3] Selects the first two book elements that are children of the bookstore element
//title[@lang] Selects all the title elements that have an attribute named lang
//title[@lang='eng'] Selects all the title elements that have an attribute named lang with a value of ‘eng’
/bookstore/book[price>35.00] Selects all the book elements of the bookstore element that have a price element with a value greater than 35.00
/bookstore/book[price>35.00]/title Selects all the title elements of the book elements of the bookstore element that have a price element with a value greater than 35.00
——————————————————————————–
Wildcard Description
* Matches any element node
@* Matches any attribute node
node() Matches any node of any kind
Path Expression Result
/bookstore/* Selects all the child nodes of the bookstore element
//* Selects all elements in the document
//title[@*] Selects all title elements which have any attribute
——————————————————————————–
Selecting Several Paths
By using the | operator in an XPath expression you can select several paths.
Path Expression Result
//book/title | //book/price Selects all the title AND price elements of all book elements
//title | //price Selects all the title AND price elements in the document
/bookstore/book/title | //price Selects all the title elements of the book element of the bookstore element AND all the price elements in the document
count
count(//first-name[.='Pet'])
Team Foundation – Removing a project
| Usage: TfsDeleteProject [/q] [/force] /server: Deletes the Team Project from Team Foundation. To use this command, you must be a member of either the Team Foundation Server Administrators group or a memberof the Project Administrators group for the project you are deleting. Use thiscommand with caution because after deleting the team project it cannot be recovered.[/q] – Do not prompt for confirmation. /server: – The name of the Team Foundation server. [/force] – Continue even if some data cannot be deleted. – The name of the project. Use quotes if there are spaces in the name. |