Archive for the ‘Uncategorized’ Category

SQL Server – Temp tables

February 12, 2007

This example

SELECT UnitCode, UnitName, UnitId, UnitParentId
INTO #ResultSet
FROM Units JOIN Parents ON (Units.UnitChildId = Parents.UnitId)
WHERE OrderId = 11 ORDER BY UnitParentId

Will create a temporal table named #ResultSet. This table will be available only on the session where it was created and as long as the session is active.

ASP – Response.Write() and Response.Redirect()

February 12, 2007

If we have the following code:

Response.Write("hello world")
Response.Redirect(”page2.asp”)

For some reason (an asp bug maybe) the redirect wont work.

But if we modify the code as follow:

Response.Redirect("page2.asp")
Response.Write(”hello world”)

Then it will work.

Edited: That’s not 100% true, sometimes it works, sometimes it doesn’t. In either case, if sometime you have a Redirect that is not working, you should keep this in mind.

ASP – POSTing

February 12, 2007

Post data from one page to another.

When posting data to a page we are requesting that page, in other words, the page is requested.

default.asp

<form name=”employeeForm” method=”post” action=”page1.asp”>
<input name=”txtName” type=”text” value=”Bob” />
<input type=”submit” name=”btnOK” value=”OK” />
</form>

page1.asp

<%
‘ Response.Write(Request(”txtName”))

‘ name = Request.Form(”txtName”)
‘ name = Request(”txtName”)

‘ Response.Write(name)

Response.Write(”<br /> Request.Form(txtName) = ” & Request.Form(”txtName”))
Response.Write(”<br /> Request(txtName) = ” & Request(”txtName”))
%>

Both Request.Form(txtName) and Request(txtName) are the same.

ASP – QueryString

February 12, 2007

Extra information that is passed along in the GET of the HTTP request, so the GET is the actual url.

page1.asp

<a href="page2.asp?myValue=Andee">Click me</a>

page2.asp

<%
‘ Dim queryStringValue

‘ queryStringValue = Request.QueryString(”myValue”)
‘ queryStringValue = Request(”myValue”)

Response.Write(”<br /> Request.QueryString(myValue) = ” & Request.QueryString(”myValue”))
Response.Write(”<br /> Request(myValue) = ” & Request(”myValue”))
%>

Both Request.QueryString() and Request() are the same