VB读取sql文并删除

 Private Sub UpdateTask()
            Dim connStr As String = ConfigurationManager.connectionStrings("TaxSoftwareConnection").ToString()
            if File.Exists(path)
                Dim file As FileInfo=New FileInfo(path)
                Dim sr As StreamReader = file.OpenText()
                Dim script As String=sr.ReadToEnd()
                Try
                    Dim conn As SqlConnection=new SqlConnection(connStr)
                    conn.Open()
                    Dim cmd As SqlCommand=conn.CreateCommand()
                    cmd.CommandText=script
                    cmd.ExecuteNonQuery()
                    conn.Close()
                Catch ex As Exception
                End Try
                 sr.Close()
                 file.Delete()

            End If
        End Sub

 

posted @ 2017-07-26 10:09  SkyLeo  阅读(319)  评论(0编辑  收藏  举报