How To generate a Complete database Script to .sql file

As a freelance i am working on my own project name myOnlineDesk. I want to make a module in admin section where i can create a database backup file and save to the system. The thing that i want is ".SQL" file. When i click on a Backup button then a complete database with stored procedures, Views and function generate a script file and able to download.

If is there any kind of help or suggestion you have please feel free to write and comment here.

I see what you are looking for, but I found this one, it is written in C# and talks to a MSSQL DB and seems to create a backup. The thing is it is a full backup of the DB not just a .SQL file. I will keep looking around and see if I can find something to help you, but in the meantime.... http://cavedweller92.wordpress.com/2012/12/13/create-backup-restoring-database-in-mssql-asp-net-c-2/
Hope that maybe will help you. Seems you could create the DB backup and then just download it or FTP it to you.

Thanks for your valuable views on this. I also analyse many blogs on internet that ".SQL" Script file cannot make a full database backup, so is there any posibility to make ".BAK" file. Can you please help me via code reference in C#.

Let me know if I can help further, I have written code in VB.net that will create a copy of a db and make it a live db as well as a lot of DB manipulation stuff, actually the copy of the DB I make could be "a backup" but like I said it is in VB.net