using System; using System.Windows.Forms; using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Shared; using System.Web.Mail; namespace WindowsApplication1 { public partial class Form1 : Form { ReportDocument cryRpt; string pdfFile = "c:\\csharp.net-informations. pdf"; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { cryRpt = new ReportDocument(); cryRpt.Load(PUT CRYSTAL REPORT PATH HERE\\CrystalReport1.rpt"); crystalReportViewer1. ReportSource = cryRpt; crystalReportViewer1.Refresh() ; } private void button2_Click(object sender, EventArgs e) { try { ExportOptions CrExportOptions ; DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions(); PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions(); CrDiskFileDestinationOptions. DiskFileName = pdfFile; CrExportOptions = cryRpt.ExportOptions; CrExportOptions. ExportDestinationType = ExportDestinationType. DiskFile; CrExportOptions. ExportFormatType = ExportFormatType. PortableDocFormat; CrExportOptions. DestinationOptions = CrDiskFileDestinationOptions; CrExportOptions.FormatOptions = CrFormatTypeOptions; cryRpt.Export(); sendmail(); } catch (Exception ex) { MessageBox.Show(ex.ToString()) ; } } private void sendmail() { try { SmtpMail.SmtpServer.Insert(0, "your hostname"); MailMessage Msg = new MailMessage(); Msg.To = "to address here"; Msg.From = "from address here"; Msg.Subject = "Crystal Report Attachment "; Msg.Body = "Crystal Report Attachment "; Msg.Attachments.Add(new MailAttachment(pdfFile)); System.Web.Mail.SmtpMail.Send( Msg); } catch (Exception ex) { MessageBox.Show (ex.ToString()); } } } }
Breaking News
Editors Picks
Wednesday, February 22, 2012
Email Crystal Reports from C# Application
Tuesday, February 21, 2012
MYSQL DROP to remove Column,Table,DataBase
MYSQL DROP to remove Column,Table,DataBase
We have seen how to remove
records from a table by using truncate
sql command. Now we will learn how to use DROP query command to delete a table
or a field or some other properties associated with the table. Let us start
with deleting a field by DROP command.
Deleting a Colunm of a Table
ALTER TABLE USER DROP UserType ;
Here user is our table
name and usertype is one of the field of this table. By this command we
can delete the field usertype of
the table User.
Deleting a Table
We can use DROP command to remove
a table inside the database. Now here is the code to delete the table User.
DROP TABLE USER
Checking before deleting
We can check whether table is
there or not before giving any delete command. Without ensuring the presence of
table ( non existence table ) delete command will generate an error message.
DROP TABLE IF EXISTS USER ;
Deleting multiple tables
We can use drop command to delete
more than one table. Here is the command to remove 4 tables.
DROP TABLE User,New_User,City,State;
The above command will delete
four tables.
DROP ING DATABASE
DROP DATABASE USER _MNG
Labels:
my sql
MYSQL COPY TABLE Command
MYSQL COPY TABLE Command
We can
copy a table structure and records to another new table. The CREATE TABLE command will
create a table with same structure of the old table and add all the records. To
export data to an existing table
you can use insert command.
create table New_users SELECT * FROM users
Copy table structure only
WE can
copy only structure and create a new table like this.
create table New_users
like
users
Create table if not exists
Note that
all the above quires will return error if the table is already exist, so to
prevent this error message we can add the command IF NOT EXISTS to the
query.
create table New_users SELECT * FROM users WHERE UserType=’Admin’
Here the
table will be created only if the table is not there before.
What we will do if we want to delete the old table and create a new table ?
What we will do if we want to delete the old table and create a new table ?
DROP TABLE IF EXISTS
Some time
we may not be sure if the table exists or not so we can drop the table if exist
by adding one more query before creating the table. Here it is
DROP
TABLE IF EXISTS ` New_users
`;
The
advantage of the above command over using a simple drop table command is here no error message saying
unknown table is generated even if the table is not there.
Copy with extra features like auto_increment
To copy
the extra features of the column like auto_increment , unique etc we have to use like this
create table New_users (recID INT(3) auto_increment primary key) SELECT * student.name,student.
UserType, student.Password FROM users
Labels:
my sql
Friday, February 3, 2012
search in gridview using asp.net
<%@ Page Language="C#"
AutoEventWireup="true"
CodeFile="TestwebPage.aspx.cs"
Inherits="TestwebPage"
%>
DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled
Pagetitle>
<script type="text/javascript">
function
Filter(Obj)
{
var
grid=document.getElementById('GridView1');
var
terms = Obj.value;
var
cellNr = "0";//grid colunm cellindex in which you want to search
var
ele;
for (var r = 1; r < grid.rows.length; r++)
{
ele =
grid.rows[r].cells[cellNr].innerHTML.replace(/<[^>]+>/g, "");
if
(ele.toLowerCase().indexOf(terms) >= 0)
grid.rows[r].style.display = '';
else
grid.rows[r].style.display = 'none';
}
};
script>
head>
<body>
<form id="form1" runat="server">
<div>
<input type="text" onkeyup="Filter(this);" />
<asp:GridView ID="GridView1" runat="server">
asp:GridView>
div>
form>
body>
html>
public partial class TestwebPage : System.Web.UI.Page
{
protected void Page_Load(object
sender, EventArgs e)
{
clsDashboard
objDB = new clsDashboard();
DataTable
dt1 = new DataTable();
string
sqlQryCity = string.Empty;
sqlQryCity = "select
Main_Node_Name from ea_treeview";
dt1 = objDB.getdatawithdt(sqlQryCity);
GridView1.DataSource = dt1;
GridView1.DataBind();
}
}
Thursday, February 2, 2012
In asp.net Sending Attachments Directly From a FileUpload
if
(FileUpload1.HasFile)
{
string toAddress
= "to_mailid";
string
fromAddress = "your_mailid";
string mailServer
= "smtp.smtpservername.com";
MailMessage
myMailMessage = new MailMessage();
myMailMessage.To.Add(toAddress);
myMailMessage.From = new MailAddress(fromAddress);
myMailMessage.Subject = "Test Message";
string fileName =
Path.GetFileName(FileUpload1.PostedFile.FileName);
Attachment
myAttachment = new Attachment(FileUpload1.FileContent,fileName);
myMailMessage.Attachments.Add(myAttachment);
SmtpClient
mySmtpClient = new SmtpClient(mailServer);
mySmtpClient.Send(myMailMessage);
}
Subscribe to:
Posts
(
Atom
)
Topics
.NET Error
AJAX and Java Script
ASP.NET
Asp.net Interview Question And Answer
aspx page to pdf
C#
C# Interview Question And Answer
C#.Oracle
CSS
Data List
Dynamic Controls
Excel
Google Map Api
Grid View
HINDI
IIS
Microsoft Certifications
MS Chart
my sql
OOPS
Oracle
Security
Send Email
Send SMS
SQL SERVER
State management
Webconfig
Windows
Windows Services
WPF
XML