如何在创建3层项目备份时获得.bak扩展名
点击备份btn它打开一个savefiledialog框但我找不到.bak扩展名保存为类型代码:private void backupdb_Load(object sender,EventArgs e)
{label4.Visible = false;
DataSet ds = SqlGetData.GetData1("select srvname from sysservers where srvproduct='SQL Server'");
for (int m = 0; m < ds.Tables[0].Rows.Count; m++)
{
cbserver.Items.Add(ds.Tables[0].Rows[0][m].ToString());
}
}
private void comboBox1_SelectedIndexChanged(object sender,EventArgs e){cbdb.Items.Clear(); DataSet ds = SqlGetData.GetData1(“从sysdatabases中选择名称”); for(int m = 0; m <ds.Tables [0] .Rows.Count; m ++){cbdb.Items.Add((ds.Tables [0] .Rows [m] [0] .ToString())。的ToString()); }}
private void button1_Click(object sender, EventArgs e)
{
blank("backup");
}
public void blank(string str)
{
if (string.IsNullOrEmpty(cbserver.Text) | string.IsNullOrEmpty(cbdb.Text))
{
label4.Visible = true;
MessageBox.Show("Server Name & Database can not be Blank");
return;
}
else
{
if (str == "backup")
{
saveFileDialog1.FileName = cbdb.Text;
saveFileDialog1.ShowDialog();
string s = null;
s = saveFileDialog1.FileName;
saveFileDialog1.Filter = "All Files|*.bak";
query("Backup database " + cbdb.Text + " to disk='" + s + "'");
label4.Visible = true;
label4.Text = "Database BackUp has been created successful";
}
}
移动该行以将过滤器设置为在显示对话框之前
saveFileDialog1.Filter = "All Files|*.bak"
saveFileDialog1.ShowDialog();
链接地址: http://www.djcxy.com/p/50335.html
上一篇: how to get .bak extension while creating backup in 3 tier project