ISCN express SQL server dumper
July 23rd, 2009
At beginning let me appreciate ISCN members ( Alireza and Morteza ) for their effort whole past a year , to night I’m placing the express SQL server dumper written by Alireza-MagicBoy , it simply dumps the database and the usage is handy easy just as he has said : copy the connection string to the blank field …
It has been coded in C# , here the source :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | <%@ Page Language="C#" EnableViewState="false" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Import Namespace="System.IO" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!--Express Sql Server Dumper - ISCN Team Tools | Coded By: Alireza-MagicBoy--> <script runat="server"> protected void btnDump_Click(object sender, System.EventArgs e) { try { SqlConnection iCon = new SqlConnection(txtSqlBackup.Text); SqlCommand iSql = new SqlCommand("", iCon); string Path = HttpContext.Current.Request.PhysicalApplicationPath; { iSql.CommandText = string.Format("backup database [{0}] to disk =@Path with INIT, SKIP, NOUNLOAD, STATS = 10", iSql.Connection.Database); iSql.CommandType = System.Data.CommandType.Text; iSql.Connection.ConnectionString = txtSqlBackup.Text; Path += iSql.Connection.Database + "_Backup.Bak"; { iSql.Parameters.AddWithValue("@Path", Path); } iCon.Open(); iSql.ExecuteNonQuery(); iCon.Close(); iSql.Dispose(); } FileStream FStream = new FileStream(Path, FileMode.Open); BinaryReader BReader = new BinaryReader(FStream); byte[] Bytes = null; Bytes = BReader.ReadBytes((int)FStream.Length); FStream.Flush(); FStream.Close(); BReader.Close(); File.Delete(Path); { Response.Expires = 0; Response.Buffer = true; Response.Clear(); Response.AddHeader("Content-Disposition", string.Format("attachment ;filename={0}",string.Concat( iSql.Connection.Database , string.Format("_Backup_rnd{0}.Bak", DateTime.Now.Millisecond)))); Response.AddHeader("Content-Length", Convert.ToString(Bytes.Length)); Response.ContentType = "application/octet-stream "; HttpContext.Current.Response.BinaryWrite(Bytes); } } catch (Exception ex) { this.Response.Write(string.Format("Error: {0}", ex.Message)); } } protected void Page_Init(object sender, System.EventArgs e) { Server.ScriptTimeout = 999999999; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Express Sql Server Dumper - ISCN Team Tools</title> </head> <body> <form id="form1" runat="server"> <div> <div> Connection String: <asp:TextBox ID="txtSqlBackup" runat="server" Width="450px"></asp:TextBox> <asp:Button ID="btnDump" runat="server" OnClick="btnDump_Click" Text="Dump" Width="81px" /></div> </div> </form> </body> </html> |
Gl till next time , be safe , Yashar .





It’s Great ! :)) Isn’t it ?