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
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
}
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
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>
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();
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;
}
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
- Open the mail.
- To display the email headers click on the inverted triangle beside Reply. Then select Show Original.
- You may can now copy the headers
Copy the mail and paste http://www.ip-adress.com/trace_email/ text box
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;
}
}
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;
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);

