Tuesday, December 15, 2009

What is Strong Name/Key

In Microsoft.Net a strong name consists of the assembly’s identity. The strong name guarantees the integrity of the assembly. Strong Name includes the name of the .net assembly, version number, culture identity, and a public key token. It is generated from an assembly file using the corresponding private key. Steps to create strong named assembly: To create a strong named assembly you need to have a key pair (public key and a private key) file.

Use sn -k KeyFile.snk Open the dot net project to be complied as a strong named assembly. Open AssembyInfo.cs/ AssembyInfo.vb file. Add the following lines to AssemblyInfo file. [Assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyDelaySign(false)] [assembly: AssemblyKeyFile("..\\..\\KeyFile.snk")] Compile the application, we have created a strong named assembly.

Asp.net Reserved/ App folder

This article is about the special "reserved" folders that are used in an ASP.NET project, such as App_Code or App_Data. Each one is discussed in details, with suggested uses for it.

Note that your ASP.NET project may or may not contain these directories. They are optional, and the uses given by Microsoft are only suggested uses. You are free to use them or not use them, for any purpose you like.

If you want to add one of these folders, go to Solution Explorer and right-click on your project's name at the top of the list. Select "Add ASP.NET folder" and pick the one(s) you want to add.

App_Data can be used to store datafiles such as databases that are used by this application. One common use is as a location to store the ASPNETDB.MDF file that is used to store usernames and passwords for authenticated website access.

App_Code is typically used to store .cs or .vb files that contain classes that are needed by your main code. Any file you put in here is automatically referenced in your main application, which is very handy. I put libraries of useful functions wrapped up in a static class here, and the compiler automatically picks them up and uses them.

App_Browsers stores special config files for individual browsers' settings. I've never needed to use this, but if you are writing code to target many unusual browsers, perhaps you could find a use for it.

App_GlobalResources is used to store .resx and .resources files, such as files for translation of your website into different languages. These files apply to the entire project.

App_LocalResources is a reserved folder name that is like App_GlobalResources, except that you can have more than one of them, in any folder in your application. It acts like a local version of App_GlobalResources that only applies to that particular folder.

App_Themes is a folder used to store any files that change the appearance of the website, such as .css files, .skin files, or images that are used in a certain theme.

Bin is the folder to put .dll files in if you want your whole application to have access to the dll file. Anything you put here, such as a third-part control, is available to your whole application.

App_WebReferences is a mystery folder that I don't understand yet!

Tuesday, December 1, 2009

Difference Between binary_checksum and checksum

binary_checksum is used to compare password only but checksum is used to compare all cases characters.

select binary_checksum('a')
select binary_checksum('A')
select checksum('a')
select checksum('A')

Result
97
65
142
142

Tuesday, November 24, 2009

Search some text from Stored Procedure

If we want to search the stored procedure name for the text then we can try

Select Distinct SO.Name from sysobjects SO (NOLOCK) INNER JOIN syscomments SC (NOLOCK) on SO.Id=SC.ID and SO.Type = 'P' AND SC.Text LIKE '%%distinct%city from dmslocation%' order by SO.Name

Tuesday, November 17, 2009

Automating Birthday Email

1. You can schedule a job at 05:00 AM every day to accompish this, just open Enterprise Manager, explorer MySQLInstance->'Management'->'SQL Server Agent'->right click 'Jobs'->'New Job', then go to 'Steps' pannel to new a step. Choose 'T-SQL' as step type, and copy your T-SQL script used for sending email to the 'Command' field (as you'll schedule the script to run once a day, let's remove the 'WHILE(1=1)' loop). Then go to 'Schedules' pannel to schedule your job step. You can press F1 for detailed help. Sorry I wrote a wrong script in my previous post, for the case that there may be more than 2 persons have same birhday:

declare @email varchar(100), @name varchar(100)

select email,name into #tbl
from tbl_Birthday
where month(birthdate)=month(getdate())
and day(birthdate)=day(getdate())
select @eamil=email,@name='Happy Birthday'+name+'!' from #tbl
WHILE (@email is not null)
BEGIN
EXEC master.dbo.xp_sendmail
@recipients = @email,
@subject = N'Happy Birthday!',
@message = @name,
@attachments='c:\happyBirth.html'--you have use attachment if you want HTML feature
DELETE FROM #tbl where email=@email
select @eamil=email,@name='Happy Birthday'+name+'!' from #tbl
END
DROP TABLE #tbl
------------------------------------
Suggested site:
http://www.howtogeek.com/howto/database/sending-automated-job-email-notifications-in-sql-server-with-smtp/

Thursday, November 5, 2009

Disabling Items Of Drop Down List

ListItem i = DropDownList1.Items.FindByValue("Finished");
i.Attributes.Add("style", "color:gray;");
i.Attributes.Add("disabled", "true");
i.Value = "-1";

Wednesday, November 4, 2009

Show Processing on Page using Modal Popup

Write the following code inside form tag and updatepanel.

< script type="text/javascript" language="javascript" >
// register for our events
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest);

function beginRequest(sender, args)
{
// show the popup
$find('mdlPopup').show();
// if we are using this fanda in master page then
// $find(' < %=mdlPopup.ClientID% >').show();
}

function endRequest(sender, args)
{
// hide the popup
$find('mdlPopup').hide();
//WindowScroll();
// if we are using this fanda in master page then
// $find(' < %=mdlPopup.ClientID% >').show();
}
< /script >

//////////////////////////

< cc1:ModalPopupExtender ID="mdlPopup" runat="server" TargetControlID="pnlPopup"
PopupControlID="pnlPopup" BackgroundCssClass="modalBackground" >
< /cc1:ModalPopupExtender >

< asp:Panel ID="pnlPopup" runat="server" CssClass="updateProgress" style="display:none" >
< div align="center" class="ProgressBarCenter" >
< asp:Image ID="img" runat="server" ImageUrl="~/Images/simple.gif" / >
< span class="updateProgressMessage" > Loading ... < /span > < /div >
< /asp:Panel >