Conerting Vb.NEt Code in Equalent c# code!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vkas
    New Member
    • Feb 2009
    • 78

    #1

    Conerting Vb.NEt Code in Equalent c# code!

    hello i had created a Vb.Net Class named Database

    I want to make the same class for C# but i am little bit unfamiliar with the syntax can any of the People Convert the below code for C#

    Code:
    Public Class Database
        Private Shared mycommand As SqlCommand
        Private Shared dr As SqlDataReader
        Private Shared da As SqlDataAdapter
        Private Shared con As SqlConnection
        Shared Function connection()
            Dim con As SqlConnection = New SqlConnection
            con.ConnectionString = "data source = (local) ; initial catalog = WisHRM ; Integrated Security = SSPI"
            Return con
        End Function
        Shared Sub GetSelectQuery(ByVal query As String)
            con = Database.connection
            con.Open()
            mycommand = New SqlCommand(query, con)
            dr = mycommand.ExecuteReader
            dr.Read()
        End Sub
        Shared Function GetResult()
            Return dr
        End Function
        Shared Sub GetDsQuery(ByVal query As String)
            con = Database.connection
            con.Open()
            da = New SqlDataAdapter(query, con)
        End Sub
        Shared Function GetDsResult()
            Return da
        End Function
        Shared Function GetUpdateQuery(ByVal query As String)
            con = Database.connection
            con.Open()
            Dim i As Integer = 0
            mycommand = New SqlCommand(query, con)
            i = mycommand.ExecuteNonQuery
            Return i
        End Function
    
    End Class
    Help me Please!!!!!!!!!
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    It wouldn't do you any good to have someone convert the code for you... you'll get far more out of it if you do it yourself. The plus side here is that .NET programs in VB, C#, and C++ convert between each other very nicely! Also, looking at the code you posted, you don't have too much to convert.

    Here's a link to a tutorial I found on google, it should get you started.
    This detailed guide to C# covers everything from setting up your development environment to understanding csharp basics like variables, control flow, and methods.


    Dive in and if you have troubles, post here and we can help you debug your conversion.

    Comment

    • Vkas
      New Member
      • Feb 2009
      • 78

      #3
      ok thanks for the idea you mean to say i must have to attempt it by myself

      ok

      Comment

      • MrMancunian
        Recognized Expert Contributor
        • Jul 2008
        • 569

        #4
        Try it yourself first, otherwise, use the .Net Reflector. You can download it at the Microsoft download site...

        Steven

        Comment

        Working...