how to get .bak extension while creating backup in 3 tier project

while click the backup btn it opened a savefiledialog box but i couldnt find .bak extension at save as type code: 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("select name from 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/50336.html

上一篇: 缩放图像而不会丢失图像质量不起作用

下一篇: 如何在创建3层项目备份时获得.bak扩展名