Click here to Skip to main content
15,917,568 members
Home / Discussions / C#
   

C#

 
GeneralRe: Issues with Converting IDataReader to DataSet Pin
DeepToot18-Dec-06 6:13
DeepToot18-Dec-06 6:13 
QuestionHow to create different versions/configurations in VS2005 Pin
frozenpondlife18-Dec-06 5:06
frozenpondlife18-Dec-06 5:06 
AnswerRe: How to create different versions/configurations in VS2005 Pin
ednrgc18-Dec-06 5:34
ednrgc18-Dec-06 5:34 
GeneralRe: How to create different versions/configurations in VS2005 Pin
frozenpondlife18-Dec-06 5:53
frozenpondlife18-Dec-06 5:53 
AnswerRe: How to create different versions/configurations in VS2005 Pin
Daniel Grunwald18-Dec-06 5:48
Daniel Grunwald18-Dec-06 5:48 
Questioni want code for authentication's to connect remote computer Pin
haneef118-Dec-06 4:29
haneef118-Dec-06 4:29 
AnswerRe: i want code for authentication's to connect remote computer Pin
ednrgc18-Dec-06 5:35
ednrgc18-Dec-06 5:35 
QuestionHow to Connect remoter computer i am getting exception error for remote as well as local computer Pin
haneef118-Dec-06 4:24
haneef118-Dec-06 4:24 
the following code for backup a database stadard form of zip file.

it is working properly for c# with windows app but not C# with asp. why i don't know.

in c# with windows also one problem it is not connecting to remote server database.











using System.Data.SqlClient;
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using SQLDMO;
using System.IO;
using System.Diagnostics;
using Shell32;
using System.Xml;
using System.Security.Permissions;
using System.Configuration;

namespace backup1
{
///
/// Summary description for WebForm1.
///

public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.TextBox t1;
protected System.Web.UI.WebControls.TextBox t2;
protected System.Web.UI.WebControls.ListBox ListBox1;
protected System.Web.UI.WebControls.ListBox lb;
protected System.Web.UI.WebControls.Button Button1;

private void Page_Load(object sender, System.EventArgs e)
{

/*SQLDMO.Application oSQLServerDMOApp = new SQLDMO.Application();
SQLDMO.NameList oNameList;
oNameList = oSQLServerDMOApp.ListAvailableSQLServers();
for (int intIndex = 0; intIndex <= oNameList.Count - 1; intIndex++)

{

if (oNameList.Item(intIndex as object) != null)

{


lb.Items.Add(oNameList.Item(intIndex).ToString());

}

}

if (lb.Items.Count > 0)
lb.SelectedIndex = 0;
else


lb.Items.Add("(local)");*/

}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.Button2.Click += new System.EventHandler(this.Button2_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion





















private void Button2_Click(object sender, System.EventArgs e)
{

string s="";
string con="";
string del2="";
string s1="";
string del1="";
int len1=0;
string k="";
string temp="";
string database1="";

string temp1="";

try
{

Login2Class s12=new Login2Class();
SQLServer2Class server = new SQLServer2Class();
Databases databases;
Database2 database;
Backup2Class backup = new Backup2Class();






//SqlConnection con11=new SqlConnection("user id=sa ; password=sa123; data source=192.168.1.6; database=pubs");
//con11.Open();

server.LoginSecure = true;
server.Connect("192.168.1.6" ,"administrator" ,"");

databases = server.Databases;


database1=t1.Text;



database = (Database2) databases.Item(database1, null);
backup.PercentCompleteNotification = 1;
backup.Database = database.Name;


int len=0;
s=TextBox2.Text;



if(s.ToUpper().EndsWith(".BAK") == true)
{

len1=s.Length;
s=s.Substring(0,len);

}

System.IO.Directory.CreateDirectory(s);

temp= System.IO.Directory.CreateDirectory(s).ToString();


s=s+"\\"+temp;






try
{

if(s.ToUpper().EndsWith(".BAK") == false)
{
s += ".bak";
}
del2=s;
backup.Files = s;
temp1=s;


backup.SQLBackup(server);



server.DisConnect();
backup = null;
server = null;




}//try


catch(Exception ex)
{
Response.Write(ex.ToString());
}




s1=s;

con="\\"+temp+".bak";


if(s1.EndsWith(con)==true)
{
len1=s1.IndexOf(con);
k=s1.Substring(0,len1);

}


con=temp+".bak";

if(s1.EndsWith(con)==true)
{
len1=s1.IndexOf(con);
s1=s1.Substring(0,len1-1);

}



del1=s1;



if(s.ToUpper().EndsWith(".ZIP") == false)
{

s1 += ".zip";
}


byte[] emptyzip = new byte[] {80,75,5,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};



FileStream fs= File.Create(s1);
fs.Write(emptyzip, 0, emptyzip.Length);
fs.Flush();
fs.Close();
fs = null;
//Copy a folder and its contents into the newly created zip file
Shell32.ShellClass sc = new Shell32.ShellClass();
Shell32.Folder SrcFlder = sc.NameSpace(k);
Shell32.Folder DestFlder = sc.NameSpace(s1);

Shell32.FolderItems items = SrcFlder.Items();

DestFlder.CopyHere(items, 0);
int i=DestFlder.Items().Count;

while(items.Count >= i)
{
System.Threading.Thread.Sleep(1000);
}
System.Threading.Thread.Sleep(1000);
System.Threading.Thread.Sleep(1000);
System.Threading.Thread.Sleep(1000);
System.IO.File.Delete(del2);
System.IO.Directory.Delete(del1);





Response.Write("zip file created in location ::" + s1);

}//try
catch(System.Runtime.InteropServices.COMException ex)
{
Response.Write(ex.ToString());

}
catch(System.Exception ex)
{
Response.Write(ex.ToString());
}






}



}
}




this is haneef

QuestionGet updated location for Control Pin
Tanuja12318-Dec-06 4:08
Tanuja12318-Dec-06 4:08 
Questionquery a datatable?? Pin
tadhg8818-Dec-06 3:52
tadhg8818-Dec-06 3:52 
AnswerRe: query a datatable?? Pin
J4amieC18-Dec-06 4:48
J4amieC18-Dec-06 4:48 
AnswerRe: query a datatable?? Pin
ToddHileHoffer18-Dec-06 4:49
ToddHileHoffer18-Dec-06 4:49 
GeneralRe: query a datatable?? [modified] Pin
tadhg8819-Dec-06 4:59
tadhg8819-Dec-06 4:59 
QuestionHow Can I Make Setup File In C#.NET 2003 Pin
kifahhk18-Dec-06 3:05
kifahhk18-Dec-06 3:05 
AnswerRe: How Can I Make Setup File In C#.NET 2003 Pin
led mike18-Dec-06 4:57
led mike18-Dec-06 4:57 
GeneralRe: How Can I Make Setup File In C#.NET 2003 Pin
ednrgc18-Dec-06 5:18
ednrgc18-Dec-06 5:18 
Questionhow incrementing the versionnumber automatically after building in VS05 Pin
b43r_3oo318-Dec-06 2:55
b43r_3oo318-Dec-06 2:55 
AnswerRe: how incrementing the versionnumber automatically after building in VS05 Pin
ednrgc18-Dec-06 5:39
ednrgc18-Dec-06 5:39 
GeneralRe: how incrementing the versionnumber automatically after building in VS05 Pin
b43r_3oo318-Dec-06 18:57
b43r_3oo318-Dec-06 18:57 
QuestionNHIBERNATE Pin
123456uio18-Dec-06 2:45
123456uio18-Dec-06 2:45 
QuestionSyncronisation between Outlook and SQL-Database Pin
TheWanderer197618-Dec-06 2:21
TheWanderer197618-Dec-06 2:21 
AnswerRe: Syncronisation between Outlook and SQL-Database Pin
ednrgc18-Dec-06 5:40
ednrgc18-Dec-06 5:40 
QuestionSimple custom ownerdraw button Pin
babbelfisken18-Dec-06 2:01
babbelfisken18-Dec-06 2:01 
AnswerRe: Simple custom ownerdraw button Pin
Eitsop19-Dec-06 0:21
Eitsop19-Dec-06 0:21 
QuestionFile transfer on LAN.......... Pin
Nagraj Naik18-Dec-06 2:00
Nagraj Naik18-Dec-06 2:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.