Tuesday 21 February 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


Wednesday 1 February 2012

In asp.net Sending Attachments Directly From a FileUpload

if(FileUpload1.HasFile)
{
    string toAddress = "to_mailid";
    stringfromAddress = "your_mailid";
    string mailServer = "smtp.smtpservername.com";
    MailMessagemyMailMessage = new MailMessage();
    myMailMessage.To.Add(toAddress);
    myMailMessage.From = new MailAddress(fromAddress);
    myMailMessage.Subject = "Test Message";
    string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
    AttachmentmyAttachment = new Attachment(FileUpload1.FileContent,fileName);
    myMailMessage.Attachments.Add(myAttachment);
    SmtpClientmySmtpClient = new SmtpClient(mailServer);
    mySmtpClient.Send(myMailMessage);
}

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Powered by Blogger