Geeks With Blogs
AzamSharp Some day I will know everything. I hope that day never comes. August 2005 Entries
Formating to Currency Format
Sometimes you need to display the variable value in the currency format. You can easily convert your values to the currently format using only 1 line of code.
double currency = 345566767;
Response.Write(String.Format("{0:C}",currency)); 

Posted On Tuesday, August 23, 2005 1:19 PM

First day of classes of last semester :)
Today is the first day of classes. I wished classes started little more late then in August. But anyway this is my last semester hopefully. Many things need to be done like finding a job, finding an apartment, buying a car. I just hope this semester goes by smoothly. Actually my class is going on right now ahhh but I am not in a mood to go on first day.

Posted On Monday, August 22, 2005 8:11 AM

Exporting GridView to Excel Link Button Problems ( RESOLVED )
I was having trouble exporting Datagrid to Excel because it contained paging and sorting links. If you try to export with linkbuttons a runtime error will be thrown. I found this cool article which resolves this problem. Check it out Exporting Datagrid to Excel For Datagrid formatting issues view my article: Exporting Datagrid to Excel ......

Posted On Sunday, August 21, 2005 8:11 PM

Generating Email List from Database using SPROC
I just wrote this small SPROC which builds the list of email address and separates them with a comma. CREATE PROCEDURE [usp_GetEmailList] @EmailList nvarchar(200) OUTPUT AS DECLARE @Email nvarchar(50) --DECLARE @EmailList nvarchar(200) SET @EmailList = '' DECLARE Email_Cursor CURSOR FOR SELECT Email FROM tblPerson OPEN Email_Cursor FETCH NEXT FROM Email_Cursor WHILE @@FETCH_STATUS = 0 BEGIN FETCH NEXT FROM Email_Cursor INTO @Email SET @EmailList = @EmailList + @Email + ',' END SET @EmailList = SUBSTRING(@EmailList,0,LEN(... ......

Posted On Sunday, August 21, 2005 7:50 PM

Preventing Users to go back to the previous pages.
Sometimes we need that after users visits once page he is not allowed to go that page again by clicking on the BACK BUTTON. You can easily add this functionality by using simple Javascript and html.
 

Posted On Saturday, August 20, 2005 4:42 PM

Creating Temporary SPROCS
Just like temporary tables in SQL SERVER 2000 you can also create temporary stored procedures.

CREATE PROC #TempProc 

@Name nvarchar(50) 

AS

SELECT * FROM tblPerson WHERE Name = @Name 

DROP PROC #TempProc 

All Temp stuff is created under tempdb..sysobjects
 
SELECT * FROM tempdb..sysobjects will return you #TempProc

Posted On Saturday, August 20, 2005 11:27 AM

Returning Friendly Message Instead of NULL Using T-SQL Query
Sometimes when retrieving data from the Database we don't want to return NULL but instead of NULL we want to return some friendly message saying 'This record is not found'. In these situations CASE function is very helpful. Look at a simple example below:
 
SELECT P.Name,Ph.PhoneNumber, 
'CellNumber' = 
CASE WHEN Ph.CellNumber IS NULL THEN 
'No CellNumber Found' 
ELSE 
Ph.CellNumber
END

FROM tblPerson P, tblPhone Ph 
WHERE P.PersonID = Ph.PersonID

Posted On Friday, August 19, 2005 1:06 PM

Populating DropDownList using Xml File
You can easily populate a DropDownList with the data from the xml file. Check out the code below: XML File hank corry david james C# CODE XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("Me... XmlNodeList nodeList = doc.SelectNodes("names/name"); foreach(XmlNode node in nodeList) DropDownList1.Items.Add(new ListItem(node.SelectSingleN... ......

Posted On Thursday, August 18, 2005 1:31 PM

Does coding makes your wife angry?

Most of the coders spent too much time infront of the screen writing code and reading articles. I wonder how annoyed their wife will be since they are not getting any attention. How do you resolve this issue? By the way I just got married but my wife is in a different state completing her studies hence the question is not directed to me.

 

 

 

Posted On Sunday, August 14, 2005 2:32 PM

Datagrid Export to Excel problems!!
I wrote an article about Exporting DataGrid to Excel which can be viewed at www.GridViewGuy.com. One question that is asked again and again was how to export the Datagrid which has the link buttons in it. If you try to export a Datagrid with link buttons inside it than it will throw an exception saying "LinkButton server control must be inside the Form tags with runat = server". If you view the html source then you will see that the LinkButton is inside the form tags with runat = server. This error ......

Posted On Sunday, August 14, 2005 1:09 PM

Dude Where are my Events?
I don't know that if you have noticed but sometimes the events on the page are deleted automatically. Like code that was working fine will not work because non of the event handlers are attached. Does anyone knows what causes this and how to prevent this?

Posted On Wednesday, August 10, 2005 1:04 PM

Debugging TIP! ( Don't follow the Yellow Brick Road )
If you want to debug a single page say "AddArticle.aspx" and that page only appears if you log in as certain user and browse couple of pages than you are wasting too much time since your target page is only "AddArticle.aspx". What you can do is open the "AddArticle.aspx" page in a new browser and than start the debugging now you are on the page that you need to debug without having to browse multiple pages. This comes really handy if you application is large and you don't want to follow the Yellow ......

Posted On Monday, August 8, 2005 12:13 PM

Unavailable for FEW DAYS !!!!
Hi Everyone, Just wanted you all to know that I will be unavailable for few days since I am getting married on August 12th 2005. Everyone take care, AzamSharp.

Posted On Monday, August 8, 2005 9:20 AM

The ugliest code I have ever written
First let me start by saying this, "The code that you will see below is the worst code I have written". Okay my requirment was to compare the date in the ACCESS database and spit out the results depending on the date. The field in the database was varchar and date was stored as '03-04-2005' (mm-dd-yyyy). Now I needed to fetch all the records of a particular month and year. The barries was the inclusion of the day in the database. The month and year was selected using the dropdownlists. Here is my ......

Posted On Saturday, August 6, 2005 9:17 PM

Open Datagrid export Excel file instantly without saving it.
When exporting Datagrid to excel you might need the file to open instantly without saving it. You can easily achieve this by using the code below. Just comment out the Response.Cache line and it will work fine. Response.Clear(); Response.AddHeader("content... "attachment;filename=FileNa... Response.Charset = ""; // Comment out the line below // Response.Cache.SetCacheabil... Response.ContentType = "application/vnd.xls"; System.IO.StringWriter stringWrite ......

Posted On Friday, August 5, 2005 11:21 AM

Inserting Data in Access Database
Talk about errors while doing a simple insert in Access Database. And the surprising thing is that you will never know what the error means since the error message is pointless. Yesterday I was executing an insert statement and keep on getting “ERROR IN THE INSERT STATEMENT”. Now I am not a psychic who can find the reason of this error by simply reading the line above but my friend google is. I found out that I was using a reserved keyword of Access, DATE. I changed my column name and it worked fine. ......

Posted On Friday, August 5, 2005 8:22 AM

Access Database Connection Nightmares :) Always close connection
Currently I am working on a project which uses Access Database. Anyway, so I designed, populated and uploaded the database to the server and it was giving me the error that "File is already being used". I was confused since the database file was not being used by any other process. Finally, I realized that error comes when you forget to close the connection. I find it really strange because it never gave me error when running on local server. It's a very bad practice to keep the connection open for ......

Posted On Monday, August 1, 2005 7:40 PM

Copyright © Mohammad Azam | Powered by: GeeksWithBlogs.net