Searching on Google for MUSIC directories, PDF files and Books, really cool video.
Monday, July 30, 2007
Tuesday, July 17, 2007
Jazz, Two Months Old !!!!!!
Tuesday, July 10, 2007
Sunday, July 8, 2007
Output Query To CSV file using Coldfusion MX and JAVA String Buffer
Using Java String buffer instead of CFFILE to convert a query to CSV file for output is much faster. Below is the code that is required, change the fileds and table name according to your dataabse.
<!--- Writing query to a CSV file using JAVA STRING BUFFER --->
<!--- get the details in a query, always use JOINS if you have more than one table --->
<cfquery name="get_records" datasource="xxxx">
select field1, field2, field3 from Table
</cfquery>
<!--- Give the location of your file where you will be writing the data --->
<cfset TempFile = (ExpandPath("dir") & ".csv") >
<!--- Create a STRING BUFFER to hold the output --->
<cfset QueryOutput = CreateObject("java","java.lang.StringBuffer").Init() >
<!--- append the column headers to string buffer, you also need to add a link break --->
<cfset QueryOutput.Append("field1, field2, field3" & chr(13) & chr(10))>
<!--- get an intial ID, so that we know when to append --->
<cfset Queryid = -1 >
<!--- loop through the query, and append the records to the buffer --->
<cfloop query="get_records">
<cfif (get_records.field1 NEQ Queryid)>
<cfset Queryid = get_records.field1 >
<cfset QueryOutput.Append("#get_records.field1#, #get_records.field2#, #get_records.field3#" & chr(13) & chr(10))>
</cfif>
<cfset QueryOutput.Append("#get_records.fields1#, #get_records.field2#, #get_records.field3#" & chr(13) & chr(10))>
</cfloop>
<!--- Write the string buffer to the file, suing ToString ---->
<cffile action="write" file="#TempFile#" output="#QueryOutput.ToString()">
<!--- End of writing query to a CSV file --->
<!--- Writing query to a CSV file using JAVA STRING BUFFER --->
<!--- get the details in a query, always use JOINS if you have more than one table --->
<cfquery name="get_records" datasource="xxxx">
select field1, field2, field3 from Table
</cfquery>
<!--- Give the location of your file where you will be writing the data --->
<cfset TempFile = (ExpandPath("dir") & ".csv") >
<!--- Create a STRING BUFFER to hold the output --->
<cfset QueryOutput = CreateObject("java","java.lang.StringBuffer").Init() >
<!--- append the column headers to string buffer, you also need to add a link break --->
<cfset QueryOutput.Append("field1, field2, field3" & chr(13) & chr(10))>
<!--- get an intial ID, so that we know when to append --->
<cfset Queryid = -1 >
<!--- loop through the query, and append the records to the buffer --->
<cfloop query="get_records">
<cfif (get_records.field1 NEQ Queryid)>
<cfset Queryid = get_records.field1 >
<cfset QueryOutput.Append("#get_records.field1#, #get_records.field2#, #get_records.field3#" & chr(13) & chr(10))>
</cfif>
<cfset QueryOutput.Append("#get_records.fields1#, #get_records.field2#, #get_records.field3#" & chr(13) & chr(10))>
</cfloop>
<!--- Write the string buffer to the file, suing ToString ---->
<cffile action="write" file="#TempFile#" output="#QueryOutput.ToString()">
<!--- End of writing query to a CSV file --->
Thursday, July 5, 2007
How to Parse XML using Coldfusion MX
XML is most widly used format to transfer data over internet. Below is the code in coldfusion which will parse a coldfusion response. I am assuming that you have stored the coldfusion response in a variable "resp"
<!--- Parse the response using XML Parse --->
<cfset xmlresp=" XMLParse(resp)">
<!--- Set the Root Element --->
<cfset rootresp=" XMLResp.XMLRoot">
<!--- Loop through the XMRoot and displaty the elements using XMLtext --->
<cfloop index="i" to="#ArrayLen(RootResp)#" from="1">
<cfset element1=" RootResp.ElementName1.XMLText">
<cfset element2=" RootResp.ElementName2.XMLText">
<!--- similary you can a access all the elements --->
</cfloop>
<!--- end of Parsing --->
That's ALL you need to do
<!--- Parse the response using XML Parse --->
<cfset xmlresp=" XMLParse(resp)">
<!--- Set the Root Element --->
<cfset rootresp=" XMLResp.XMLRoot">
<!--- Loop through the XMRoot and displaty the elements using XMLtext --->
<cfloop index="i" to="#ArrayLen(RootResp)#" from="1">
<cfset element1=" RootResp.ElementName1.XMLText">
<cfset element2=" RootResp.ElementName2.XMLText">
<!--- similary you can a access all the elements --->
</cfloop>
<!--- end of Parsing --->
That's ALL you need to do
How to Output Query In Excel Format Using Coldfusion MX
Couple of Projects that I am working on required to download the data from database in Excel fromat, so that the client can download it on his local system.
One of the efficient way I have found is using Query2Excel Tag which is available FREE on internet. You can download if from www.cflib.org
Below code is just how to call that function, for excel download.
<!--- Query to get information from database --->
<cfquery name="get_info" datasource="#whatever#">
select name1, name2, name3 from yourdatabase
</cfquery>
<!--- give the column names and headers for Excel file --->
<cfscript>
cols = "name1, name2, name3";
heads = "Name1, Name2, Name3"
</cfscript>
<!--- use CFHEADER tag --->
<cfheader name="Content-Disposition" value="inline; filename=data.xls">
<cfcontent type="application/msexcel">
<!--- output the results using the query2excel function --->
<cfoutput> #Query2Excel(get_info, heads, cols)# </cfoutput>
<!--- End of code --->
That's all you need :-)
One of the efficient way I have found is using Query2Excel Tag which is available FREE on internet. You can download if from www.cflib.org
Below code is just how to call that function, for excel download.
<!--- Query to get information from database --->
<cfquery name="get_info" datasource="#whatever#">
select name1, name2, name3 from yourdatabase
</cfquery>
<!--- give the column names and headers for Excel file --->
<cfscript>
cols = "name1, name2, name3";
heads = "Name1, Name2, Name3"
</cfscript>
<!--- use CFHEADER tag --->
<cfheader name="Content-Disposition" value="inline; filename=data.xls">
<cfcontent type="application/msexcel">
<!--- output the results using the query2excel function --->
<cfoutput> #Query2Excel(get_info, heads, cols)# </cfoutput>
<!--- End of code --->
That's all you need :-)
SQL Server Interview Questions
SQL server interview questions
Q1. What is the difference between a primary and unique key?
Ans1. Both primary key and unique enforce uniqueness of the column on whichthey are defined. But by default primary key creates a clustered indexon the column, where are unique creates a nonclustered index bydefault. Another major difference is that, primary key doesn't allowNULLs, but unique key allows one NULL only.
Q2. What is bit datatype and what information is stored in a bit column?
Ans2. Information stored 0, 1, Null
Q3. What is the difference between delete table and truncate table?
Ans3. DELETE TABLE is a logged operation, so the deletion of each row getslogged in the transaction log, which makes it slow. TRUNCATE TABLE also deletes all the rows in a table, but it won't log the deletion of each row, instead it logs the deallocation of the data pages of thetable, which makes it faster. TRUNCATE TABLE can be rolledback.
Q4. How to find the 6th highest salary from EMPLOYEES table?
Ans4. Select TOP 1 salary from (Select DISTINCT TOP 6 salary from EMPLOYEES order by salary desc) Order by salary.
Q5. What is a Deadlock?
Ans5. Deadlock is a situation when two processes, each having a lock on one piece of Data, attempting to acquire lock on other's piece.
Q6. What is the difference between UNION and JOINS?
Ans6. A join selects COLUMNS from 2 or more tables, while UNION selects ROWS.
Q1. What is the difference between a primary and unique key?
Ans1. Both primary key and unique enforce uniqueness of the column on whichthey are defined. But by default primary key creates a clustered indexon the column, where are unique creates a nonclustered index bydefault. Another major difference is that, primary key doesn't allowNULLs, but unique key allows one NULL only.
Q2. What is bit datatype and what information is stored in a bit column?
Ans2. Information stored 0, 1, Null
Q3. What is the difference between delete table and truncate table?
Ans3. DELETE TABLE is a logged operation, so the deletion of each row getslogged in the transaction log, which makes it slow. TRUNCATE TABLE also deletes all the rows in a table, but it won't log the deletion of each row, instead it logs the deallocation of the data pages of thetable, which makes it faster. TRUNCATE TABLE can be rolledback.
Q4. How to find the 6th highest salary from EMPLOYEES table?
Ans4. Select TOP 1 salary from (Select DISTINCT TOP 6 salary from EMPLOYEES order by salary desc) Order by salary.
Q5. What is a Deadlock?
Ans5. Deadlock is a situation when two processes, each having a lock on one piece of Data, attempting to acquire lock on other's piece.
Q6. What is the difference between UNION and JOINS?
Ans6. A join selects COLUMNS from 2 or more tables, while UNION selects ROWS.
ASP.Net Interview Questions
Below are some of the questions that I asked a candidate who came for interview for a ASP.Net Developer.
Q1. What is an Interface and What is an Abstract Class?
Ans1. In an Interface all methods must be Abstract, In Abstract class some methods can be defined.
Q2. Can Two different Programming Languages be mixed in a single ASPX file?
Ans2. ASP.Net's built in parsers are used to remove code from ASPX file and create language files. Each Parser understands only one language, therefore mixing of languages in a single ASPX file is not possible.
Q3. Is it possible to see the code that ASP.Net generates from ASPX files.?
Ans3. Yes, By enabling debugging using <%@ Page Debug = "true"> in ASPX file or <compilation debug = "true"> in web.config file.
Q4. How do I create an ASPX page that periodically refreshes itself in n seconds?
Ans4. <meta http-enquiv="Refresh" Content="nn">
Q5. Explain Webservices
Ans5. WebServices are programmable business logic components that provide access to informaiton functionality through Internet. Standard Protocols like HTTP can be used to access them. WebServices are based on SOAP which is an application of XML.
Q6. Explain Namespaces
Ans6. Namespaces are logical groupings of names used within a program.
Q7. Can A custom .NET data type be used in a web form?
Ans7. Yes, by placing the DLL containing the data type in application root bin directory and ASP.net will automatically load the DLL.
Q1. What is an Interface and What is an Abstract Class?
Ans1. In an Interface all methods must be Abstract, In Abstract class some methods can be defined.
Q2. Can Two different Programming Languages be mixed in a single ASPX file?
Ans2. ASP.Net's built in parsers are used to remove code from ASPX file and create language files. Each Parser understands only one language, therefore mixing of languages in a single ASPX file is not possible.
Q3. Is it possible to see the code that ASP.Net generates from ASPX files.?
Ans3. Yes, By enabling debugging using <%@ Page Debug = "true"> in ASPX file or <compilation debug = "true"> in web.config file.
Q4. How do I create an ASPX page that periodically refreshes itself in n seconds?
Ans4. <meta http-enquiv="Refresh" Content="nn">
Q5. Explain Webservices
Ans5. WebServices are programmable business logic components that provide access to informaiton functionality through Internet. Standard Protocols like HTTP can be used to access them. WebServices are based on SOAP which is an application of XML.
Q6. Explain Namespaces
Ans6. Namespaces are logical groupings of names used within a program.
Q7. Can A custom .NET data type be used in a web form?
Ans7. Yes, by placing the DLL containing the data type in application root bin directory and ASP.net will automatically load the DLL.
Subscribe to:
Posts (Atom)
Blog Archive
-
▼
2007
(18)
-
▼
July
(8)
- Searching on Google, Really Cool stuff !!!!!
- Jazz, Two Months Old !!!!!!
- FRIENDS All Seasons Download Links !!!!!!!!
- Output Query To CSV file using Coldfusion MX and J...
- How to Parse XML using Coldfusion MX
- How to Output Query In Excel Format Using Coldfusi...
- SQL Server Interview Questions
- ASP.Net Interview Questions
-
▼
July
(8)