CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Mar 2007
    Posts
    144

    Visual Basic to C# Script

    Can anyone help me convert the following VB script to C#

    Code:
    Public Sub Main()
        Dim conn As New SqlConnection("server=(local);Integrated Security=SSPI;database=Test")
        
         AddHandler conn.InfoMessage, New SqlInfoMessageEventHandler(AddressOf OnInfoMessage)
         
         conn.Open()
         
         Dim cmd As New SqlCommand()
         cmd.Connection = conn
         cmd.CommandType = CommandType.StoredProcedure
         cmd.CommandText = "SPWithPrint"
         cmd.ExecuteNonQuery()
         conn.Close()
         Dts.TaskResult.Results.Success
         
    End Sub
    
    Private Sub OnInfoMessage(ByVal sender As Object, ByVal args As System.Data.SqlClient.SqlInfoMessageEventArgs)
        Dim sqlEvent As System.Data.SqlClient.SqlError
         For Each sqlEvent In args.Errors
                Dts.Events.FireInformation(sqlEvent.Number, sqlEvent.Procedure, sqlEvent.Message, "", 0, False)
            Next
    End Sub
    Last edited by versacestl; April 30th, 2010 at 10:00 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured