My Struggle - VB6 to VB.NET

UdiHrant

Member
Joined
Jul 3, 2012
Messages
9
Programming Experience
10+
I'm really trying guys - honestly. But the books I have are either too simple and only use controls or go into squirrly code snippets that are damn hard to follow. ANY HELP WILL BE APPRECIATED HERE...

Two basic questions first :

1 - all the books I have say that the way to start working with VB.NET and SQL is to build a data bound item by dragging my data source onto an empty form. That will create a default datagrid object with the right code behind it. Ok - yes - that works fine. But what if I don't want to have a datagrid control showing on my form. I make it visible=false but the navigation controls still appear at the top of my form!

2 - More importantly though, the VB6 programs I need to rewrite all involve manipulating strings and modifying exiting rows in a sql database. That was easy in VB6 using the fields property like this -

DataEnvironment3.rsIU_Biograph.Fields("Gender") = "M"

For the life of me I cannot find the equivelent of this statement in VB.NET

Here is some code that I tried but I can't figure out the right syntax for the remmed out statement at line 26...

I think I can get or replace a 'field' from my sql database through a property on the binding source but I can't figure out the syntax!


01Public Class Form1

02

03 Private Sub MIS_JOBSBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MIS_JOBSBindingNavigatorSaveItem.Click

04 Me.Validate()

05 Me.MIS_JOBSBindingSource.EndEdit()

06 Me.TableAdapterManager.UpdateAll(Me.IntraWebDataSet)

07

08 End Sub

09

10 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

11 'TODO: This line of code loads data into the 'IntraWebDataSet.MIS_JOBS' table. You can move, or remove it, as needed.

12 Me.MIS_JOBSTableAdapter.Fill(Me.IntraWebDataSet.MIS_JOBS)

13

14 End Sub

15

16 Private Sub BtnQUIT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnQUIT.Click

17 End

18 End Sub

19

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

21 Me.MIS_JOBSBindingSource.MoveLast()

22 ' Label1.Text = Me.MIS_JOBSBindingSource.Item.field("description")

23 End Sub

24

25 Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

26

27 End Sub

28End Class





ANY help will be appreciated!
 
Your #1 makes no sense to me anyways. Learning how to bind data objects should NOT be the first thing you learn in .NET. Learning how to work with an object should be.

VB6 is not object-oriented. It tries to pretend to be, through ActiveX, but it is not. Your original code (
DataEnvironment3.rsIU_Biograph.Fields("Gender") = "M" ) uses a RecordSet, part of what seems to be a DataSet. Nothing of that changes in VB.NET. If you still want to use ADO, you have nothing to change to that statement.

Let's see you first try to convert as much code as you can, and then ask specifically what causes issues.
 
Back
Top