Connect and share knowledge within a single location that is structured and easy to search. I have these databases accounts , information and data. I need a help to download database data as. And for your extra information, that database contains 5 tables. I want to download all into a single file. I should also be able to upload the same. It should replace the available data database.
I know its possible via phpmyadmin and cannot use it as I am going to let my clients download the sql file. And I cannot give them my phpmyadmin password. And more-over its not essential that I need to do it via. I suggest that you write a bash script that do what I've wrote before. It could send the dump to another server or whatever you want. Use php for this is a bit strange. I guess it is vulnerable to hand-over database uploading to Clients.
I've learned it from this comment. Thank you, Henrik. I would suggest to use dibi DB layer. I don't think every user can run the 'exec' function on the server where his projects ran on. As you already have the mysql account as well as the permission of running php website.
Why not try to install phpmyadmin in the web server. It can satisfy you with various kind of functionalities. It also written in php. You can generate a sql dump file with the shell command mysqldump. The restore from a sql file can be done by using the mysql shell command. Within PHP the shell commands can be called with the function exec :. SetCacheability HttpCacheability. NoCache ;. BinaryWrite bytes ;.
Flush ;. End ;. Parse TryCast sender, LinkButton. Dim bytes As Byte. AddWithValue " Id" , id. BinaryWrite bytes. Related Articles. Add Comments. Thank you for the feedback.
The comment is now awaiting moderation. You will be notified via email when the author replies to your comment. Please select a comment to reply. You can add your comment about this article using the form below.
Make sure you provide a valid email address else you won't be notified when the author replies to your comment Please note that all comments are moderated and will be deleted if they are Not relavant to the article Spam Advertising campaigns or links to other sites Abusive content. Please do not post code, scripts or snippets.
Required Invalid Email Address. The only focus of this example is to upload and download files, so I did not pay any attention on OO design, Design Patterns, and coding standards. For simplicity, I did not even put exception handling in the code. NET to access the database, but you can definitely use more advanced techniques such as Entity Framework , Hibernate , and Stored Procedures to take advantage of whatever advantages these techniques can provide you.
NET for those interested. Although I did not test it myself since I do not have earlier versions myself, I feel that you can simply copy and paste the code in your application in earlier versions. In this article, I will first introduce how to create the SQL Server database for this application and then show you how to upload and download files in this ASP.
NET application. To create the database, you need to have "administrative" permissions in SQL Server. You can run the following script to create the database:. The above script is "safe". To preview which data will be generated to an Excel file, click the Preview button:.
The Complete the Wizard window shows all options that are chosen for exporting operations. The last SQL Server Import and Export Wizard window shows the state of the data have been successfully exported or some errors occurred during exporting data:.
In our case, the data were successfully generated into the SQL Data. In a query editor type and execute the following code:. After executing the above code, the following message will appear that indicate that the show advanced options and Ad Hoc Distributed Queries options are enabled:.
It is already opened exclusively by another user, or you need permission to view and write its data. This usually happens because of inadequate permissions. More about how to resolving these issues can be found in the How to query Excel data using SQL Server linked servers page.
One way for resolving this issue is to open SSMS as an administrator and execute the code again. But this time, another error may appear:. Msg , Level 16, State 1, Line 1 Column name or number of supplied values does not match table definition.
0コメント