Select * from sys.procedures where [type] = 'P' and is_ms_shipped = 0 and [name] not like 'sp[_]%diagram%'
Select 'Drop Procedure ' + name from sys.procedures Where [type] = 'P'
and is_ms_shipped = 0
and [name] not like 'sp[_]%diagram%'
Run the second query in your SQL Server 2005 after selecting database, then copy all output for the ran query and then runt those copied query.
All your stored procedure will get deleted.
Thursday, March 13, 2008
Tuesday, March 4, 2008
Javascript Validation
function check()
{
if(document.getElementById("<%=txtfname.ClientID%>").value == "")
{
alert ('Please enter first name');
return false;
}
else
{
if(document.getElementById("<%=txtlnm.ClientID%>").value == "")
{
alert ('Please enter last name');
return false;
}
else
{
if(document.getElementById("<%=txtemail.ClientID%>").value == "")
{
alert ('Please enter email ID');
return false;
}
else
{
if(emailValidator(document.getElementById("<%=txtemail.ClientID%>"), "Invalid EmailID"))
{
return true;
}
else
{
if(document.getElementById("<%=txtpswrd.ClientID%>").value == "")
{
alert ('Please enter password');
return false;
}
else
{
var psword = document.getElementById("<%=txtpswrd.ClientID%>");
if(passwordValidator(psword,"Invalid Password. Enter Password as 4 digit birth year and last 4 digits of SSN "))
{
return true;
}
else
{
return false;
}
}
}
}
}
}
}
}
function emailValidator(elem, helperMsg)
{
var emailExp = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
if (elem.value != "")
{
if(elem.value.match(emailExp))
{
}
else
{
alert(helperMsg);
elem.focus();
return false;
}
}
}
function passwordValidator(elem, helperMsg)
{
var passwordExp = /^[0-9]+$/;
if(elem.value != "")
{
if(elem.value.match(passwordExp))
{
return true;
}
else
{
alert(helperMsg);
elem.focus;
return false;
}
}
}
{
if(document.getElementById("<%=txtfname.ClientID%>").value == "")
{
alert ('Please enter first name');
return false;
}
else
{
if(document.getElementById("<%=txtlnm.ClientID%>").value == "")
{
alert ('Please enter last name');
return false;
}
else
{
if(document.getElementById("<%=txtemail.ClientID%>").value == "")
{
alert ('Please enter email ID');
return false;
}
else
{
if(emailValidator(document.getElementById("<%=txtemail.ClientID%>"), "Invalid EmailID"))
{
return true;
}
else
{
if(document.getElementById("<%=txtpswrd.ClientID%>").value == "")
{
alert ('Please enter password');
return false;
}
else
{
var psword = document.getElementById("<%=txtpswrd.ClientID%>");
if(passwordValidator(psword,"Invalid Password. Enter Password as 4 digit birth year and last 4 digits of SSN "))
{
return true;
}
else
{
return false;
}
}
}
}
}
}
}
}
function emailValidator(elem, helperMsg)
{
var emailExp = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
if (elem.value != "")
{
if(elem.value.match(emailExp))
{
}
else
{
alert(helperMsg);
elem.focus();
return false;
}
}
}
function passwordValidator(elem, helperMsg)
{
var passwordExp = /^[0-9]+$/;
if(elem.value != "")
{
if(elem.value.match(passwordExp))
{
return true;
}
else
{
alert(helperMsg);
elem.focus;
return false;
}
}
}
Creating Virtual Directories in IIS through coding
private void CreateVirtualDir(string WebSite, string AppName, string Path)
{
System.DirectoryServices.DirectoryEntry IISSchema = new System.DirectoryServices.DirectoryEntry("IIS://" + WebSite + "/Schema/AppIsolated");
bool CanCreate = !(IISSchema.Properties("Syntax").Value.ToString.ToUpper() == "BOOLEAN");
IISSchema.Dispose();
if (CanCreate) {
bool PathCreated;
try {
System.DirectoryServices.DirectoryEntry IISAdmin = new System.DirectoryServices.DirectoryEntry("IIS://" + WebSite + "/W3SVC/1/Root");
//make sure folder exists
if (!System.IO.Directory.Exists(Path)) {
System.IO.Directory.CreateDirectory(Path);
PathCreated = true;
}
//If the virtual directory already exists then delete it
foreach (System.DirectoryServices.DirectoryEntry VD in IISAdmin.Children) {
if (VD.Name == AppName) {
IISAdmin.Invoke("Delete", new string[] {VD.SchemaClassName, AppName});
IISAdmin.CommitChanges();
break; // TODO: might not be correct. Was : Exit For
}
}
//Create and setup new virtual directory
System.DirectoryServices.DirectoryEntry VDir = IISAdmin.Children.Add(AppName, "IIsWebVirtualDir");
VDir.Properties("Path").Item(0) = Path;
VDir.Properties("AppFriendlyName").Item(0) = AppName;
VDir.Properties("EnableDirBrowsing").Item(0) = false;
VDir.Properties("AccessRead").Item(0) = true;
VDir.Properties("AccessExecute").Item(0) = true;
VDir.Properties("AccessWrite").Item(0) = false;
VDir.Properties("AccessScript").Item(0) = true;
VDir.Properties("AuthNTLM").Item(0) = true;
VDir.Properties("EnableDefaultDoc").Item(0) = true;
VDir.Properties("DefaultDoc").Item(0) = "default.htm,default.aspx,default.asp";
VDir.Properties("AspEnableParentPaths").Item(0) = true;
VDir.CommitChanges();
//the following are acceptable params
//INPROC = 0
//OUTPROC = 1
//POOLED = 2
VDir.Invoke("AppCreate", 1);
}
catch (Exception Ex) {
if (PathCreated) {
System.IO.Directory.Delete(Path);
}
throw Ex;
}
}
}
{
System.DirectoryServices.DirectoryEntry IISSchema = new System.DirectoryServices.DirectoryEntry("IIS://" + WebSite + "/Schema/AppIsolated");
bool CanCreate = !(IISSchema.Properties("Syntax").Value.ToString.ToUpper() == "BOOLEAN");
IISSchema.Dispose();
if (CanCreate) {
bool PathCreated;
try {
System.DirectoryServices.DirectoryEntry IISAdmin = new System.DirectoryServices.DirectoryEntry("IIS://" + WebSite + "/W3SVC/1/Root");
//make sure folder exists
if (!System.IO.Directory.Exists(Path)) {
System.IO.Directory.CreateDirectory(Path);
PathCreated = true;
}
//If the virtual directory already exists then delete it
foreach (System.DirectoryServices.DirectoryEntry VD in IISAdmin.Children) {
if (VD.Name == AppName) {
IISAdmin.Invoke("Delete", new string[] {VD.SchemaClassName, AppName});
IISAdmin.CommitChanges();
break; // TODO: might not be correct. Was : Exit For
}
}
//Create and setup new virtual directory
System.DirectoryServices.DirectoryEntry VDir = IISAdmin.Children.Add(AppName, "IIsWebVirtualDir");
VDir.Properties("Path").Item(0) = Path;
VDir.Properties("AppFriendlyName").Item(0) = AppName;
VDir.Properties("EnableDirBrowsing").Item(0) = false;
VDir.Properties("AccessRead").Item(0) = true;
VDir.Properties("AccessExecute").Item(0) = true;
VDir.Properties("AccessWrite").Item(0) = false;
VDir.Properties("AccessScript").Item(0) = true;
VDir.Properties("AuthNTLM").Item(0) = true;
VDir.Properties("EnableDefaultDoc").Item(0) = true;
VDir.Properties("DefaultDoc").Item(0) = "default.htm,default.aspx,default.asp";
VDir.Properties("AspEnableParentPaths").Item(0) = true;
VDir.CommitChanges();
//the following are acceptable params
//INPROC = 0
//OUTPROC = 1
//POOLED = 2
VDir.Invoke("AppCreate", 1);
}
catch (Exception Ex) {
if (PathCreated) {
System.IO.Directory.Delete(Path);
}
throw Ex;
}
}
}
Friday, February 29, 2008
Export gridview to excel at button click
when u want to export a gridview at button click and one thing to note that grid view is present in master-content page then go for below code ::
protected void imgbtnExport_Click(object sender, ImageClickEventArgs e)
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=Users.xls");
Response.Charset = "";
Response.ContentType = "~/ReportOutputs/abc.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
System.Web.UI.WebControls.GridView dg = new System.Web.UI.WebControls.GridView();
objDs = user.getUser();
if (objDs != null && objDs.Rows.Count > 0)
{
dg.DataSource = objDs;
dg.DataBind();
}
dg.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
We have to generate a new grid view at runtime and have to bind the data to the new grid with the data previously present in the grid.
But if the grid view is in form tag then no need to generate a new gridview, just give the id of grid to rendercontrol and it will work.....
protected void imgbtnExport_Click(object sender, ImageClickEventArgs e)
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=Users.xls");
Response.Charset = "";
Response.ContentType = "~/ReportOutputs/abc.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
System.Web.UI.WebControls.GridView dg = new System.Web.UI.WebControls.GridView();
objDs = user.getUser();
if (objDs != null && objDs.Rows.Count > 0)
{
dg.DataSource = objDs;
dg.DataBind();
}
dg.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
We have to generate a new grid view at runtime and have to bind the data to the new grid with the data previously present in the grid.
But if the grid view is in form tag then no need to generate a new gridview, just give the id of grid to rendercontrol and it will work.....
Friday, February 22, 2008
Suppressing 4 level drill down crystal report
Hi
Go through below mentioned step to suppress 4 level drill down reports ::
Firstly, do grouping with 4 groups.
I
n Report header keep the chart and then goto section expert select suppress check box write
drilldowngrouplevel > 0
In group1 header keep groupname and summary field goto section expert and write
drilldowngrouplevel > 1
then insert section below the group header and keep chart and then goto section expert write
drilldowngrouplevel <> 1.
In group2 header keep groupname and summary field then goto section expert and write
drilldowngrouplevel > 2
then insert section below the group header
and keep the chart and then goto section expert write
drilldowngrouplevel <> 2
Go through below mentioned step to suppress 4 level drill down reports ::
Firstly, do grouping with 4 groups.
I
n Report header keep the chart and then goto section expert select suppress check box write
drilldowngrouplevel > 0
In group1 header keep groupname and summary field goto section expert and write
drilldowngrouplevel > 1
then insert section below the group header and keep chart and then goto section expert write
drilldowngrouplevel <> 1.
In group2 header keep groupname and summary field then goto section expert and write
drilldowngrouplevel > 2
then insert section below the group header
and keep the chart and then goto section expert write
drilldowngrouplevel <> 2
Generate pdf through ASP.NET
Hi,
I will be generating pdf reports through ASP.NET2.0 and Crystal Report 10.0, add this code in your page load....
protected void Page_Load(object sender, EventArgs e)
{
rptDoc.Load(Server.MapPath("~/Reports/FeedbackReport_AdminMsngRpt.rpt"));
// Make your connection string rptDoc.SetDatabaseLogon(ConfigurationManager.AppSettings["DBLogin"].ToString(), ConfigurationManager.AppSettings["DBPassword"].ToString(), ConfigurationManager.AppSettings["DBServer"].ToString(), ConfigurationManager.AppSettings["DBase"].ToString());
con.ReportConnection(rptDoc, cnInfo, crDb, crTables);
ParameterDiscreteValue paraDiscVal = new ParameterDiscreteValue();
ParameterValues paraRpt = new ParameterValues();
foreach (ParameterFieldDefinition paraDefTemp in rptDoc.DataDefinition.ParameterFields)
{
switch (paraDefTemp.Name)
{
case "ReportNumber":
paraDiscVal.Value = Request.QueryString["RptNo"].ToString();
paraRpt.Add(paraDiscVal);
paraDefTemp.ApplyCurrentValues(paraRpt);
break;
case "@reportnumber":
paraDiscVal.Value = Request.QueryString["RptNo"].ToString();
paraRpt.Add(paraDiscVal);
paraDefTemp.ApplyCurrentValues(paraRpt);
break;
default:
paraDiscVal.Value = null;
paraRpt.Add(paraDiscVal);
paraDefTemp.ApplyCurrentValues(paraRpt);
break;
}
}
//rptDoc.RecordSelectionFormula = " {RH_Report.ReportNumber}=" + Request.QueryString["RptNo"].ToString();
ExportOptions crExportOptions;
DiskFileDestinationOptions crDiskFileDestinationOptions = new DiskFileDestinationOptions(); ;
string Fname;
//Export the Report To Pdf format.
//Uncomment below line for Criteria Non Compliance Report
//Fname = Server.MapPath("ReportOutputs/") + Session["lstReports"].ToString().Replace("/", "_").Replace(" ", "_").Replace("-", "_") + "_" + DateTime.Now.Date.ToShortDateString().Replace("/", "_") + "_" + DateTime.Now.ToShortTimeString().Replace(":", "_") + ".pdf";
//Comment this line when u will uncomment above line.
Fname = Server.MapPath("ReportOutputs/") + Request.QueryString["RptNo"].ToString() + ".pdf";
Session["Fname"] = Fname;
crDiskFileDestinationOptions = new DiskFileDestinationOptions();
crDiskFileDestinationOptions.DiskFileName = Fname;
crExportOptions = rptDoc.ExportOptions;
{
crDiskFileDestinationOptions.DiskFileName = Server.MapPath("ReportOutputs/") + Request.QueryString["RptNo"].ToString() + ".pdf";
crExportOptions.DestinationOptions = crDiskFileDestinationOptions;
crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
}
rptDoc.Export();
Session.Add("report", rptDoc);
CrystalReportViewer1.ReportSource = (ReportDocument)Session["report"];
//Code to export report in pdf
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.WriteFile(Fname);
Response.Flush();
Response.Close();
//delete the exported file from disk
System.IO.File.Delete(Fname);
}
I will be generating pdf reports through ASP.NET2.0 and Crystal Report 10.0, add this code in your page load....
protected void Page_Load(object sender, EventArgs e)
{
rptDoc.Load(Server.MapPath("~/Reports/FeedbackReport_AdminMsngRpt.rpt"));
// Make your connection string rptDoc.SetDatabaseLogon(ConfigurationManager.AppSettings["DBLogin"].ToString(), ConfigurationManager.AppSettings["DBPassword"].ToString(), ConfigurationManager.AppSettings["DBServer"].ToString(), ConfigurationManager.AppSettings["DBase"].ToString());
con.ReportConnection(rptDoc, cnInfo, crDb, crTables);
ParameterDiscreteValue paraDiscVal = new ParameterDiscreteValue();
ParameterValues paraRpt = new ParameterValues();
foreach (ParameterFieldDefinition paraDefTemp in rptDoc.DataDefinition.ParameterFields)
{
switch (paraDefTemp.Name)
{
case "ReportNumber":
paraDiscVal.Value = Request.QueryString["RptNo"].ToString();
paraRpt.Add(paraDiscVal);
paraDefTemp.ApplyCurrentValues(paraRpt);
break;
case "@reportnumber":
paraDiscVal.Value = Request.QueryString["RptNo"].ToString();
paraRpt.Add(paraDiscVal);
paraDefTemp.ApplyCurrentValues(paraRpt);
break;
default:
paraDiscVal.Value = null;
paraRpt.Add(paraDiscVal);
paraDefTemp.ApplyCurrentValues(paraRpt);
break;
}
}
//rptDoc.RecordSelectionFormula = " {RH_Report.ReportNumber}=" + Request.QueryString["RptNo"].ToString();
ExportOptions crExportOptions;
DiskFileDestinationOptions crDiskFileDestinationOptions = new DiskFileDestinationOptions(); ;
string Fname;
//Export the Report To Pdf format.
//Uncomment below line for Criteria Non Compliance Report
//Fname = Server.MapPath("ReportOutputs/") + Session["lstReports"].ToString().Replace("/", "_").Replace(" ", "_").Replace("-", "_") + "_" + DateTime.Now.Date.ToShortDateString().Replace("/", "_") + "_" + DateTime.Now.ToShortTimeString().Replace(":", "_") + ".pdf";
//Comment this line when u will uncomment above line.
Fname = Server.MapPath("ReportOutputs/") + Request.QueryString["RptNo"].ToString() + ".pdf";
Session["Fname"] = Fname;
crDiskFileDestinationOptions = new DiskFileDestinationOptions();
crDiskFileDestinationOptions.DiskFileName = Fname;
crExportOptions = rptDoc.ExportOptions;
{
crDiskFileDestinationOptions.DiskFileName = Server.MapPath("ReportOutputs/") + Request.QueryString["RptNo"].ToString() + ".pdf";
crExportOptions.DestinationOptions = crDiskFileDestinationOptions;
crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
}
rptDoc.Export();
Session.Add("report", rptDoc);
CrystalReportViewer1.ReportSource = (ReportDocument)Session["report"];
//Code to export report in pdf
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.WriteFile(Fname);
Response.Flush();
Response.Close();
//delete the exported file from disk
System.IO.File.Delete(Fname);
}
Gridview Hyperlink : Navigate URL with more than one parameter in query string
Add in your hyperlink asp button (Navigate URL)::
NavigateUrl='<%# "frmUserManagement.aspx?HID=" + DataBinder.Eval(Container.DataItem,"HID") + "&UID=" + DataBinder.Eval(Container.DataItem,"UID")%>'
NavigateUrl='<%# "frmUserManagement.aspx?HID=" + DataBinder.Eval(Container.DataItem,"HID") + "&UID=" + DataBinder.Eval(Container.DataItem,"UID")%>'
Subscribe to:
Posts (Atom)