Results 1 to 6 of 6

Thread: [2.0] VB.net to C#

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    240

    [2.0] VB.net to C#

    I have an existing system written in VB.net and the database I used was MSAccess, and I would like to convert it into web application using asp.net written in C# and the database platform is SQL Server. Do you think I could still used my codes in VB.net especially for the following and convert it into C#:

    1. Connection to the SQL Database
    2. Add Records to the SQL Database
    3. Edit and Update Records to the SQL Database
    4. Delete Records to the SQL Database

    How's the conversion? Is it a hard work to do? And is it true that PHP is much better than the ASP.net using C#? My colleagues told me that PHP works better than ASP.net?

    Here is the sample code:
    Code:
    Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
            Dim cm As CurrencyManager
            If IsNothing(dsVolumeGenDiscount) Then Exit Sub
    
            cm = CType(BindingContext(dsVolumeGenDiscount, "tblVolGenDiscount"), CurrencyManager)
    
            'check if record is empty
            Dim A As Integer
            A = Me.BindingContext(dsVolumeGenDiscount, "tblVolGenDiscount").Count
            If A = 0 Then
                MsgBox("Record is empty!", MsgBoxStyle.Information)
                Exit Sub
            End If
    
            Dim id As Integer
            Dim dr As DataRowView = CType(cm.Current, DataRowView)
            id = CType(dr.Item("DiscountID"), Integer)
    
            Dim dsE As DataSet = GetDetail(id)
    
            Binder(dsE)
            'Me.LoadData()
    
            If txtChkGen.Text = "yes" Then
                chkGenDiscount.Checked = True
            End If
    
            btnEdit.Visible = False
            btnAdd.Enabled = False
            btnDelete.Enabled = False
            btnSave.Visible = True
    
            'Me.cboCountry.DataBindings.Clear()
            'Me.cboEquipment.DataBindings.Clear()
            'Me.txtCostPerEquip.DataBindings.Clear()
            'Me.txtDocID.DataBindings.Clear()
        End Sub
    Thank you in advance!

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] VB.net to C#

    Data access is not specific to WebForms or WinForms. If you had kept the data access code in its own library you could have just plugged it into an ASP.NET application "as is", regardless of development language. That's where good planning and design come into software development.

    As it is now, you can just extract your data access code into its own library or a new application and convert to C# if required. Most code converters will get you most of the way there.

    You can then switch your OLEDB provider from Jet to SQL Server, or preferably switch from OleDb completely to SqlClient. All the code structure will be essentially the same. You'll simply change from an OleDb class to the equivalent SqlClient class, e.g. from OleDbConnection to SqlConnection.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    240

    Re: [2.0] VB.net to C#

    What makes my life more easy in converting my existing system into a web application?

    Since my existing system is already written in VB.net, what if I'm going to use ASP.net using vb instead of using c#? Which one is best in Web Application? ASP.NET using vb or ASP.NET using c#?

  4. #4
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: [2.0] VB.net to C#

    Essentially I would prefer using the one that I know most. They are mostly same as long as you know the underlying framework. It is the .NET Framework Class Libraries that you are going to use in both C# and VB.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    240

    Re: [2.0] VB.net to C#

    Actually I am only new for both languages for web application, and I find difficulty to find the best solution for my system to convert it into web. Can you help me find the best reference for C# and sql database that I can be used for converting my existing system into a web application using asp.net?

  6. #6
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: [2.0] VB.net to C#

    Here are couple of very good tutorials that will help you start learning ASP.NET. These can also be found by searching on Google.

    ASP.NET Tutorial
    C# ASP.NET Tutorial
    Use [code] source code here[/code] tags when you post source code.

    My Articles

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