1,105,375 Community Members

How To generate a Complete database Script to .sql file

Member Avatar
prashant9928
Newbie Poster
10 posts since Sep 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
NardCake
Posting Pro in Training
417 posts since Oct 2012
Reputation Points: 30 [?]
Q&As Helped to Solve: 30 [?]
Skill Endorsements: 9 [?]
 
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.

Member Avatar
hometownnerd
Junior Poster in Training
50 posts since Sep 2007
Reputation Points: 13 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 4 [?]
 
0
 

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

Member Avatar
hometownnerd
Junior Poster in Training
50 posts since Sep 2007
Reputation Points: 13 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 4 [?]
 
1
 

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

Member Avatar
prashant9928
Newbie Poster
10 posts since Sep 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
hometownnerd
Junior Poster in Training
50 posts since Sep 2007
Reputation Points: 13 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 4 [?]
 
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

Member Avatar
prashant9928
Newbie Poster
10 posts since Sep 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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. :)

Question Answered as of 1 Year Ago by hometownnerd and NardCake
Member Avatar
hometownnerd
Junior Poster in Training
50 posts since Sep 2007
Reputation Points: 13 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 4 [?]
 
0
 

Very cool, glad you got it worked out!!

Have a great day

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: