public void sentMail(string from,string to,string subject,string body)
{
MailMessage mailObj = new MailMessage(from,to,subject, body);
SmtpClient SMTPServer = new SmtpClient(“localhost”);
try
{
SMTPServer.Send(mailObj);
Label1.Text = “Mail Sent”;
}
catch (Exception ex)
{
Label1.Text = ex.ToString();
}
}
Monthly Archives: December 2012
Send mail using local SMPT server
Using aspnet_regsql via the command line to setup membership roles
Open the command promt with admin rights and change the directory to
C:\WINDOWS\Microsoft.NET\Framework\<versionNumber>\
You can run the Aspnet_regsql.exe tool as a command-line utility
Aspnet_regsql.exe –S servername –d databasename –U username –P password –A <optionsto be install>
After install
To Uninstall
Referance : http://msdn.microsoft.com/en-us/library/x28wfk74(v=vs.100).aspx
Various options to export Excel
First time I worked in generating Excel report, there are different ways to generate the excel file.
1) Using drivers
2) Using Microsoft.Office.Interop.Excel
3) Using Open XML
4) Closed XML (Code plex)
5) EPPlus (code plex)
I tried to export the excel using ‘drivers’ as in ‘Export to excel in ASP.NET‘ but while exporting to export it i have to use Gridview, which is not suitable for my requirment (differentiate null value and default values).
‘Microsoft.Office.Interop.Excel’ :-
To make use of this dll i have to install VSTO. if office is not installed in the development box or production box i can’t install the VSTO. This also not met my requirement since any of the office product i have to install.
Open XML:-
Using OpenXML it is easy to create EXCEL document and format it. but only drawback for me is have large lines of code. We can overcome by using ‘Open XML SDk 2.0 Productivity Tool‘. This tool reduces the code and it generates the code automatically for the opened excel file template.
This ‘Closed XML‘ helped me to reduce lines of code in exporting data from Dataset to Excel. we can download the ClosedXML from codeplex site. In ClosedXML also use OpenXML dll and as for i used this closedXML is good and easy to use for basic operations.
How to give a database access to specific users only?
SINGLE_USER allows any single user with permission to access the database.
ALTER DATABASE [Database Name] SET SINGLE_USER
ALTER DATABASE [Database Name] SET Multi_USER
RESTRICTED_USER is the one that limits access to sysadmin, dbowner, or dbcreator