Playing with INFORMATION_SCHEMA

http://www.devx.com/getHelpOn/10MinuteSolution/20561

Recap: INFORMATION_SCHEMA (a part of SQL-92 standard) is very useful if you want to retrieve the metadata of the database you are working on. For instance, you may want to retrieve a list of all databases in your SQL server or a list of columns in a specific table. Here are some queries that relate to my project recently.

Retrieve all current databases in the SQL server:

Select * from INFORMATION_SCHEMA.SCHEMATA

As you notice the return result, the field named “CATALOG_NAME” is “DATABASE” name. This is how SQL-92 Name is slightly different from SQL Server Name. Thus, if you want the database name only, this is what you should change:

Select CATALOG_NAME from INFORMATION_SCHEMA.SCHEMATA order by CATALOG_NAME asc

Now we’re drilling down the database metadata. Let’s retrieve tables in a specific database:

Use ‘databasename’
Select * from INFORMATION_SCHEMA.TABLES

Retrieve columns in a specific table:

Select * from INFORMATION_SCHEMA.COLUMNS
Where TABLE_NAME=’tablename’

What the Hack

www.whatthehack.org
What: “a largely self-organizing outdoor hacker conference/event” with open training workshops
Who: presentations presented by security experts and hackers (list)
When: it is halfway to its end (28 July 2005 - 31 July 2005)
Where: Netherlands (hello people over there…can anyone get me a ticket? I pay you back when you visit the US. Thanks a lot :D)
How: buy me a ticket , i’ll show u how
Featured topics: Symbian security, Attacks on Digital Passports, Security of memory allocators for C and CPP,Hash Functions, Spoofing fingerprints in 10 minutes :D (list)

And special thx to Enki Boehm’s blog for a little more details on this event :).

Popup window and refresh page issue

ASP.NET, JavaScript

Working on my recent project, i ran into a common problem that most developers have had when they are dealing with user input and page refresh. The requirement is the webpage needs a way to popup a window, let the user input the data. After the form is submitted, the popup is closed, and the original webpage is refreshed with new data already filled in. The solution is simple, but it took me awhile to find out the best answer that fits what i want.

I just point out the important thing of how i approached this problem rather than going into detail the code. The major things lay on how we refresh the original window (also called the opener in Javascript) and how we fill the form with user input.

Session variables are the the answer for the 2nd problem. Simply store all user inputs into session variables, and when the original page (opener) refreshes, make sure you check these session variables and fill out the fields appropriately if those sessions are not empty (but make sure you “empty” those session as well after you fill in the values or after the main form is processed unless you have to invoke the popup multiple times).

To refresh the original page (opener), insert this script to wherever you may want to invoke it (e.g: a button, a link):

<script language=’javascript’>
{ opener.window.location=opener.window.location;self.close();}
</script>

In VB.NET, you can add to the event handler of a button as:

Response.Write(”<script language=’javascript’> {opener.window.location=opener.window.location;self.close();}</script>”)

Yup, it’s just simple like that. The reason i bring this up because i want it to be my reference later on since there are some helps out there if you Google, but most of them don’t fit what i want. For instance, you can insert a meta tag to refresh the page, but you have to specify the time delay so that the page can refresh after certain intervals (I just want the page to be refreshed when I want only). Or the other workaround is to declare a javascript function in the original window as: document.location.reload()and call this function when the form in the popup window is submitted. This one works fine except for the annoying popup msg asking if you want to send data to the server (of course we want the server to get the session variables to process).

Note: I haven’t tested this on Firefox, Netscape or other browsers for the compatibility

Visual Studio 2005 expected in Fall

.NET developer community have been waiting for the official version of Visual Studio 2005 after successful series of beta testing from Microsoft (it doesn’t mean a bug-free application though). A lot more features are integrated into .NET platform. Other Microsoft products which had never been related to Visual Studio before such as MS SQL Server are now partly coordinated with the application. If back-end database developers always consider writing and editing stored/user-defined procedures or triggers a pain due to lack of clarification for debugging or time-consuming typing, they would find out Visual Studio 2005 their company to simplify these tasks. With integrated intellisense feature, procedures and triggers can be handled with ease. Perhaps Microsoft is doing a great job in taking care of programmers in term of time saving and accuracy ;).

Set/Get Session Object in ASP.NET

This code snippet in VB.NET is very handy if you want to save an object as session variable and then retrieve it for later use. I run into this matter very often and it’s just lazy to type all of them. In the future, i just grab these lines of code from here yeahhhhh (such a lazy nerd :D)

Private const SESSIONVARNAME = “aname”

Public Sub SaveInSession(ByVal ctx As HttpContext)
ctx.Session(SESSIONVARNAME) = Me
End Sub

Public Shared Function GetSessionObject(ByVal ctx As HttpContext) As WorkOrderSearch
Dim o As Object
o = ctx.Session(SESSIONVARNAME)
If Not o Is Nothing Then
Return CType(o, WorkOrderSearch)
Else
Return New WorkOrderSearch
End If
End Function

*WorkOrderSearch: name of the object

Next Page »