Drop all stored procedures

USE DBNAME
GO

declare @procName sysname

declare someCursor cursor for
select name from sysobjects where type = ‘P’ and objectproperty(id, ‘IsMSShipped’) = 0

open someCursor
fetch next from someCursor into @procName
while @@FETCH_STATUS = 0
begin
exec(‘drop proc ‘ + @procName)
fetch next from someCursor into @procName
end

close someCursor
deallocate someCursor
go

May 3, 2011 at 11:26 am Leave a comment

File Upload Code ASP.NET + C#

string FilePath = “”;
string[] a = new string[1];
string fileName = “”;
string FullName = “”;

if (FileUploader.FileName.Length > 0)
{
a = FileUploader.FileName.Split(‘.’);
fileName = Convert.ToString(System.DateTime.Now.Ticks) + “.” + a.GetValue(1).ToString();
FilePath = Server.MapPath(@”~\SavedFolder”);
Fup1.SaveAs(FilePath + @”\” + fileName);

FullName = FilePath + @”\” + fileName;
// Database Saved Code
}

May 3, 2011 at 10:06 am Leave a comment

Find stored procedure

DECLARE @StringToSearch varchar(100)
SET @StringToSearch = ‘Bank’

SET @StringToSearch = ‘%’ +@StringToSearch + ‘%’
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 @StringToSearch
ORDER BY SO.Name
GO

May 3, 2011 at 5:21 am Leave a comment

Page Hit counter asp.net,c#

.cs page

protected void Page_Load(object sender, EventArgs e)

{

this.countMe();
DataSet tmpDs = new DataSet();
tmpDs.ReadXml(Server.MapPath(“~/counter.xml”));

lblCounter.Text = tmpDs.Tables[0].Rows[0]["hits"].ToString();

}

private void countMe()
{
DataSet tmpDs = new DataSet();
tmpDs.ReadXml(Server.MapPath(“~/counter.xml”));

int hits = Int32.Parse(tmpDs.Tables[0].Rows[0]["hits"].ToString());

hits += 1;

tmpDs.Tables[0].Rows[0]["hits"] = hits.ToString();

tmpDs.WriteXml(Server.MapPath(“~/counter.xml”));
}

.xml page

<?xml version=”1.0″ standalone=”yes”?>
<counter>
<count>
<hits>6</hits>
</count>
</counter>

March 16, 2010 at 9:53 am 1 comment

Getting folder name from drive and Getting file name from folder in C#

// Getting foldername from a deive
List<string> flist = new List<string>();
DirectoryInfo fdInfo = new DirectoryInfo(@”Z:\”);
DirectoryInfo[] sdinfo = dInfo.GetDirectories();
TextWriter ftw = new StreamWriter(“folderinfo.txt”);
foreach (DirectoryInfo subd in sdinfo)
{
ftw.WriteLine(subd.Name);
}
ftw.Flush();
ftw.Close();

// Getting filename from a folder
List<string> list = new List<string>();
DirectoryInfo dInfo = new DirectoryInfo(@”Z:\”);
FileInfo[] FilesList = dInfo.GetFiles();
TextWriter tw = new StreamWriter(“fileName.txt”);
foreach (FileInfo fi in FilesList)
{
tw.WriteLine(fi.Name);
}
tw.Flush();
tw.Close();

December 3, 2009 at 5:55 am Leave a comment

Password Generator

protected void btnGenerate_Click(object sender, EventArgs e)
{
string allowedChars = “”;
allowedChars = “a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,”;
allowedChars += “A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,”;
allowedChars += “1,2,3,4,5,6,7,8,9,0″;

char[] sep = { ‘,’ };
string[] arr = allowedChars.Split(sep);
string passwordString = “”;
string temp = “”;

Random rand = new Random();
for (int i = 0; i < 6; i++)
{
temp = arr[rand.Next(0, arr.Length)];
passwordString += temp;
}
txtPassword.Text = passwordString;
}

November 21, 2009 at 7:49 am Leave a comment

Email Trace – Email Tracking

Simply Copy and Paste below the email header of the message into the box below on this page to trace an email. This email tracer pinpoints the location of the senders IP address.

  • · Yahoo Mail
    1. Right click on the message
    2. Click”Show Full Header”
    3. Now you can copy and paste the Email header
  • · Google Mail – Gmail
  1. Open the mail.
  2. To display the email headers click on the inverted triangle beside Reply. Then select Show Original.
  3. You may can now copy the headers

images

Copy the mail and paste http://www.ip-adress.com/trace_email/ text box

October 31, 2009 at 9:08 am Leave a comment

Safe your Login info Guard Against Request !!

Use the method in your User textbox and Password textbox

As like::
String loginID = GuardAgainstRequest(tbxUserID.Text.Trim());
String loginPass =GuardAgainstRequest(tbxPass.Text.Trim());

public static string GuardAgainstRequest(string reqString)
{
if (reqString != null)
{
string[] strToReplace = {“select”, “drop”, “update”, “delete”, “xp_”, “insert”, “–”, “;”, “\”", “=”, “/”, “\\”, “()”, “^”, “~”, “`”, “‘”, “””};

for (int i =0; i < strToReplace.Length; i++)
{
if (strToReplace[i] == “–”)
{
reqString = reqString.Replace(strToReplace[i], “..”);
}
else if (strToReplace[i] == “‘”)
{
reqString = reqString.Replace(strToReplace[i], “””);
}
else
{
reqString = reqString.Replace(strToReplace[i], “?”);
}
}
return reqString;
}
else
{
return null;
}
}

August 24, 2009 at 7:06 am Leave a comment

Get first day and last day year in C# .net

nMupYear.Enabled = true;

DateTime _From = new DateTime(Convert.ToInt32(nMupYear.Value),1,1);
DateTime _to = new DateTime(Convert.ToInt32(nMupYear.Value),12,31);

dtPickerDtFrom.Value = _From.Date;
dtPickerDtTo.Value = _to.Date;

August 16, 2009 at 4:13 am Leave a comment

Get first day and last day on the month in C# .Net

First Day

dtPickerDtFrom.Value = new DateTime(Convert.ToInt32(nMupYear.Value), Convert.ToInt32(cBxMonth.SelectedIndex + 1), 1)

Last Day

dtPickerDtTo.Value =   dtPickerDtFrom.Value.AddMonths(1).AddDays(-1);

August 16, 2009 at 4:08 am Leave a comment

Older Posts


Calendar

January 2012
M T W T F S S
« May    
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Follow

Get every new post delivered to your Inbox.