Monday, 30 April 2012

TO PERFORM BULK COPY FROM ONE DATABASE TO ANOTHER IN ASP.NET



C#
  
  using system.data.sqlclient;

button click
{

    string sqlQuery = "Select * From publishers";
    string connString = "Data Source=Local;Initial Catalog=PUBS;Integrated Security=True";
    SqlConnection sourceConn= new SqlConnection(connString);
    SqlConnection destConn = new SqlConnection(connString);
    sourceConn.Open();
    destConn.Open();
    SqlCommand command = new SqlCommand(sqlQuery, sourceConn);
    SqlDataReader reader = command.ExecuteReader();
    SqlBulkCopy bulkCopy = new SqlBulkCopy(destConn);
    bulkCopy.DestinationTableName = "BulkCopyPublishers";
    bulkCopy.WriteToServer(reader);
    bulkCopy.Close();
    sourceConn.Close();
    destConn.Close();
    Label1.Text = "Data copied successfully";
}

Saturday, 28 April 2012

MAIL GRID VIEW USING ASP.NET

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;
using System.IO;
using System.Text;

public partial class Csharp : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

    }


    public void fn_AttachGrid()

    {

        StringWriter stw = new StringWriter();

        HtmlTextWriter hw = new HtmlTextWriter(stw);

        GridView1.RenderControl(hw);

        MailMessage mail = new MailMessage();

        mail.IsBodyHtml = true;

        mail.To.Add(new MailAddress("toMail@domain.com"));

        mail.Subject = "Sales Report";

        System.Text.Encoding Enc = System.Text.Encoding.ASCII;

        byte[] mBArray = Enc.GetBytes(stw.ToString());

        System.IO.MemoryStream mAtt = new System.IO.MemoryStream(mBArray, false);

        mail.Attachments.Add(new Attachment(mAtt, "sales.xls"));

        mail.Body = "Hi PFA";

        SmtpClient smtp = new SmtpClient();

        mail.From = new MailAddress("fromMail@domain.com", "Your Name");

        smtp.Host = "mail.domain.com";

        smtp.UseDefaultCredentials = false;

        smtp.Credentials = new System.Net.NetworkCredential(@"Username", "Password");

        smtp.EnableSsl = true;

        smtp.Send(mail);

        lbldisplay.Text = "Email Sent";

    }

    public override void VerifyRenderingInServerForm(Control control)

    {

    }


    protected void btnSendMail_Click(object sender, EventArgs e)

    {
fn_AttachGrid();

    }

}

Friday, 27 April 2012

URL TO VIEW TRACK IT JOBS STATISTIC

                                         http://www.itjobswatch.co.uk/

SENDING EMAIL USING ASP.NET

 protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            MailMessage msg = new MailMessage();

            msg.From = new MailAddress("fromaddress@gmail.com");

            msg.To.Add(Totestbox.Text);

            msg.Subject = subtextbox.Text;

            msg.IsBodyHtml = true;

            msg.Body = bodytextbox.Text;

            msg.Priority = MailPriority.High;

            SmtpClient client = new SmtpClient("smtp.gmail.com", 587);

            client.UseDefaultCredentials = false;

            client.Credentials = new System.Net.NetworkCredential("fromaddress@gmail.com", "password");

            client.Port = 587;

            client.Host = "smtp.gmail.com";

            client.EnableSsl = true;

            client.Send(msg);
            Label1.Text = "mail sent";
        }
        catch (Exception ex)
        {
            Label1.Text ="mail not sent" + ex.Message ;
        }

    } 

ASCII CODES

Key     Code
backspace     8
tab     9
enter     13
shift     16
ctrl     17
alt     18
pause/break     19
caps lock     20
escape     27
page up     33
page down     34
end     35
home     36
left arrow     37
up arrow     38
right arrow     39
down arrow     40
insert     45
delete     46
0     48
1     49
2     50
3     51
4     52
5     53
6     54
7     55
8     56
9     57
a     65
b     66
c     67
d     68
        
Key     Code
e     69
f     70
g     71
h     72
i     73
j     74
k     75
l     76
m     77
n     78
o     79
p     80
q     81
r     82
s     83
t     84
u     85
v     86
w     87
x     88
y     89
z     90
left window key     91
right window key     92
select key     93
numpad 0     96
numpad 1     97
numpad 2     98
numpad 3     99
numpad 4     100
numpad 5     101
numpad 6     102
numpad 7     103
        
Key     Code
numpad 8     104
numpad 9     105
multiply     106
add     107
subtract     109
decimal point     110
divide     111
f1     112
f2     113
f3     114
f4     115
f5     116
f6     117
f7     118
f8     119
f9     120
f10     121
f11     122
f12     123
num lock     144
scroll lock     145
semi-colon     186
equal sign     187
comma     188
dash     189
period     190
forward slash     191
grave accent     192
open bracket     219
back slash     220
close braket     221
single quote     222
    

DISABLE BACK BUTTON

<script type = "text/javascript">

function disableBackButton(){ 

window.history.forward();

}
</script>

</head> 

<body onload="disableBackButton()">

</body>

Thursday, 5 May 2011

FEW FIREFOX SHORT CUT KEYS


                                              FIREFOX SHORTCUT KEYS    
                       Firefox is the second most popular web browser in the world and it continues to gain popularity and market share. With this rapid growth many users, especially new users, are not aware of the wide range of useful Firefox keyboard shortcuts available. These small combinations of keystrokes when used at the right time can be real productivity boosters. Here are 30 Firefox keyboard shortcuts to help simplify and speed up your daily browsing. Even Firefox veterans may find these useful.

Many of the shortcuts will be a combination of keystrokes. For example “Ctrl + C” means that you should hold down the Ctrl (control) key and press the letter “C”. Use the lowercase letters not uppercase, if using the shift key is need it will be indicated as “Shift”.
Page Navigation Shortcuts
These shortcuts allow you to navigate quickly around a web page, most with only a single keystroke.
* Spacebar — Page down one full screen at a time
* Shift – Spacebar — Page up one full screen at a time
* Down Arrow – Scroll down
* Page Down — Page down one full screen at a time
* Up Arrow – Scroll Up
* Page Up — Page up one full screen at a time
* End – Go to the Bottom (end) of the page
* Home – Go to the Top of page
Pages, Tabs and Bookmarks
These useful shortcuts help you quickly perform different common tasks within Firefox, manage Tabs and access bookmarks.
* F5 — Reload the current page
* Alt + Home — Go to home page
* Ctrl + L — Go to the Address bar
* Ctrl + K — Go to the search box
* Ctrl + = — Increase the text size, zoom in
* Ctrl + – — Decrease the text size, zoom out
* Ctrl + P — Print the current page
* Ctrl + H — Opens the Browsing History in a column on the left
* Ctrl + T — Open a new tab
* Ctrl + W — Close current tab
* Ctrl + Tab — rotate forward to the next tab
* Ctrl + Shft + Tab — rotate back to the previous tab
* Ctrl + 1-9 — Choose a number to jump to that specific tab
* Ctrl + B — Open Bookmarks Column on Left
* Ctrl + I — Close Bookmarks Column
* Ctrl + D – Create a bookmark for the current page
*Ctrl + Shft + T – this opens the previous tab(s) that were closed.
Mouse Shortcuts
Here are six mouse-related shortcuts for when you already have your hand on the mouse. These shortcuts include the scroll wheel and utilize the clicking function (middle click) of the scroll wheel.
* Shift – scroll down – Go to the previous page
* Shift – scroll up – Go to the next page
* Ctrl – scroll up — Decrease the text size, zoom out
* Ctrl – scroll down — Increase text size, zoom in
* Middle click on link — Open the link in a new tab
* Middle click on a tab — Close the tab
back to top