我的b/s结构软件升级包

从没看过别人如何写升级包,我想是不是能有这类的自动化工具?这个程序应该比较通用。

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        If CheckBox1.Checked = True Then
            Dim dirinfo As DirectoryInfo = New DirectoryInfo(AppFolder.Text)
            If dirinfo.Exists = False Then
                MessageBox.Show("程序安装文件夹不存在,请重新填写.", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
                GoTo myFlagError
            End If


            Dim AppUpdate As New Process
            AppUpdate.StartInfo.FileName = "xcopy.exe"
            AppUpdate.StartInfo.Arguments = String.Format("{0} {1} /s /y", "App", AppFolder.Text)
            Try
                AppUpdate.Start()
                AppUpdate.WaitForExit()
                AppUpdate.Close()
                MessageBox.Show("程序已经成功升级!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
            Catch ex As Exception
                MessageBox.Show("升级程序失败!请联系北京****公司.", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
            End Try
        End If

            '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
            '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
            If CheckBox2.Checked = True Then
                Dim connString As String = String.Format("workstation id=.;packet size=4096;user id={0};pwd={1};data source=.;persist security info=False;initial catalog={2}", DBAdmin.Text, DBPasswd.Text, DBName.Text)
                Try
                    Dim TestInteger As Integer = SqlHelper.ExecuteScalar(connString, CommandType.Text, "select count(*) from sysusers")
                Catch ex As Exception
                    MessageBox.Show("数据库连接失败,请检查所填写数据库信息是否正确.", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
                    GoTo myFlagError
                End Try


                Dim Succ As Boolean = True
                Dim SQLUpdate As New Process
                Dim files As FileInfo
                Dim dir As DirectoryInfo = New DirectoryInfo("Sql/")
                For Each files In dir.GetFiles

                    SQLUpdate.StartInfo.FileName = "osql.exe"
                    SQLUpdate.StartInfo.Arguments = String.Format("-U {0} -P {1} -d {2} -i {3}", DBAdmin.Text, DBPasswd.Text, DBName.Text, "Sql/" & files.Name)
                    Try
                        SQLUpdate.Start()
                        SQLUpdate.WaitForExit()
                        SQLUpdate.Close()

                    Catch ex As Exception
                        MessageBox.Show("升级数据库脚本 " & files.Name & " 失败!请联系北京****公司.", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
                        Succ = False
                    End Try
                Next
                If Succ = True Then
                    MessageBox.Show("数据库脚本已经成功升级!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
                End If
            End If

myFlagError:  ' 连接数据库失败出错!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值