We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,866 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

How To generate a Complete database Script to .sql file

Hello everyone,

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.

3
Contributors
7
Replies
5 Days
Discussion Span
2 Months Ago
Last Updated
33
Views
Question
Answered
prashant9928
Newbie Poster
9 posts since Sep 2010
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

PHP, ignore.

I'm SORRY I did it again! I see something like this on the homepage and assume it's php, and it's asp.net...
I apologize, I will try to find something though.

You could try the exec() function to execute a command to do such.

exec('mysqldump --user=... --password=... --host=... DB_NAME > /path/to/output/file.sql');

As seen here: http://stackoverflow.com/questions/6750531/using-a-php-file-to-generate-a-mysql-dump
(A simple Google search)
Then for the download you could just link the location of the file, the browser should automatically download it.

NardCake
Posting Whiz in Training
270 posts since Oct 2012
Reputation Points: 20
Solved Threads: 19
Skill Endorsements: 8

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.

Have a good day,
Larry

hometownnerd
Light Poster
37 posts since Sep 2007
Reputation Points: 21
Solved Threads: 4
Skill Endorsements: 2

Here is an interesting post, I found....seems to make a full .sql file, maybe try that out. http://www.codeproject.com/Articles/21067/Create-SQL-Server-Database-using-asp-net

Larry

hometownnerd
Light Poster
37 posts since Sep 2007
Reputation Points: 21
Solved Threads: 4
Skill Endorsements: 2

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#.

prashant9928
Newbie Poster
9 posts since Sep 2010
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

The first link I sent had code in it for making a BAK file for the DB... http://cavedweller92.wordpress.com/2012/12/13/create-backup-restoring-database-in-mssql-asp-net-c-2/ It even shows how to restore the data, but since I do not write in C# I am not a lot of help with it. Hopefully it can help you out when you see it.

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

Larry

hometownnerd
Light Poster
37 posts since Sep 2007
Reputation Points: 21
Solved Threads: 4
Skill Endorsements: 2

Thanks Mr. hometownnerd, Its helps me a lot. I have done the coding in C# and its working perfectly even i can also manipulate the db's while taking backup. :)

prashant9928
Newbie Poster
9 posts since Sep 2010
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0
Question Answered as of 2 Months Ago by hometownnerd and NardCake

Very cool, glad you got it worked out!!

Have a great day

hometownnerd
Light Poster
37 posts since Sep 2007
Reputation Points: 21
Solved Threads: 4
Skill Endorsements: 2

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0812 seconds using 2.72MB