Upgrade VB6 Database to VB10
-
I wrote a large Database program in VB6 that worked well for many years. Now I am trying to re-write that program in VB10. I was able to figure out how to make everything work except for the main element, the Database controls. Is there something that I can read to learn how the new code works? Thanks, Garner
-
I wrote a large Database program in VB6 that worked well for many years. Now I am trying to re-write that program in VB10. I was able to figure out how to make everything work except for the main element, the Database controls. Is there something that I can read to learn how the new code works? Thanks, Garner
-
When you say Database controls, are you talking about UI or at a data access level. An example code snippet would also help answer your question.
"You get that on the big jobs."
Now I think I’m worse off than I originally thought since I don’t even know how to answer your question. Guessing “UI” means “User Interface?” If so, I think that is where my problem is. Here’s the old VB6 code I used for my “Update” button in the user interface. VB10 highlights just about all of it with all kinds of errors. The worst part is that I have several buttons in each of several interfaces controlling several databases. “Add,” “Update,” “Delete,” & “Refresh” are the buttons that I am using.
Private Sub cmdUpdate_Click() On Error GoTo UpdateErr Dim db As Database Set db = OpenDatabase("c:\microsoft visual studio\vb98\openaccts.mdb") Dim rs As Recordset Set rs = db.OpenRecordset("prices", dbOpenDynaset) 'Edit record and show new prices. rs.Edit rs.Fields("1b") = txtFields(0) rs.Fields("2b") = txtFields(1) rs.Fields("2r") = txtFields(2) rs.Fields("3a") = txtFields(3) rs.Fields("3s") = txtFields(4) rs.Fields("as") = txtFields(5) rs.Fields("br") = txtFields(6) rs.Fields("bs") = txtFields(7) rs.Fields("fd") = txtFields(8) rs.Fields("ms") = txtFields(9) rs.Fields("os") = txtFields(10) rs.Fields("ts") = txtFields(11) rs.Fields("tu") = txtFields(12) rs.Fields("ws") = txtFields(13) rs.Update 'Change prices on PRODUCT form. frmprdm!txt1b.text = rs.Fields("1b") frmprdm!txt2b.text = rs.Fields("2b") frmprdm!txt3a.text = rs.Fields("3a") frmprdm!txt3u.text = rs.Fields("3s") frmprdm!txtas.text = rs.Fields("as") frmprdm!txtbr.text = rs.Fields("br") frmprdm!txtbs.text = rs.Fields("bs") frmprdm!txtfd.text = rs.Fields("fd") frmprdm!txtms.text = rs.Fields("ms") frmprdm!txtou.text = rs.Fields("os") frmprdm!txtts.text = rs.Fields("ts") frmprdm!txttu.text = rs.Fields("tu") frmprdm!txtws.text = rs.Fields("ws") Exit Sub UpdateErr: MsgBox Err.Description End Sub
I have read a ton of information online about changing the code and; so far, none of it has worked for me. Thanks, Garner -
Now I think I’m worse off than I originally thought since I don’t even know how to answer your question. Guessing “UI” means “User Interface?” If so, I think that is where my problem is. Here’s the old VB6 code I used for my “Update” button in the user interface. VB10 highlights just about all of it with all kinds of errors. The worst part is that I have several buttons in each of several interfaces controlling several databases. “Add,” “Update,” “Delete,” & “Refresh” are the buttons that I am using.
Private Sub cmdUpdate_Click() On Error GoTo UpdateErr Dim db As Database Set db = OpenDatabase("c:\microsoft visual studio\vb98\openaccts.mdb") Dim rs As Recordset Set rs = db.OpenRecordset("prices", dbOpenDynaset) 'Edit record and show new prices. rs.Edit rs.Fields("1b") = txtFields(0) rs.Fields("2b") = txtFields(1) rs.Fields("2r") = txtFields(2) rs.Fields("3a") = txtFields(3) rs.Fields("3s") = txtFields(4) rs.Fields("as") = txtFields(5) rs.Fields("br") = txtFields(6) rs.Fields("bs") = txtFields(7) rs.Fields("fd") = txtFields(8) rs.Fields("ms") = txtFields(9) rs.Fields("os") = txtFields(10) rs.Fields("ts") = txtFields(11) rs.Fields("tu") = txtFields(12) rs.Fields("ws") = txtFields(13) rs.Update 'Change prices on PRODUCT form. frmprdm!txt1b.text = rs.Fields("1b") frmprdm!txt2b.text = rs.Fields("2b") frmprdm!txt3a.text = rs.Fields("3a") frmprdm!txt3u.text = rs.Fields("3s") frmprdm!txtas.text = rs.Fields("as") frmprdm!txtbr.text = rs.Fields("br") frmprdm!txtbs.text = rs.Fields("bs") frmprdm!txtfd.text = rs.Fields("fd") frmprdm!txtms.text = rs.Fields("ms") frmprdm!txtou.text = rs.Fields("os") frmprdm!txtts.text = rs.Fields("ts") frmprdm!txttu.text = rs.Fields("tu") frmprdm!txtws.text = rs.Fields("ws") Exit Sub UpdateErr: MsgBox Err.Description End Sub
I have read a ton of information online about changing the code and; so far, none of it has worked for me. Thanks, GarnerRead up on DataTables, DataSets and DataRows - that should help. :)
-
I wrote a large Database program in VB6 that worked well for many years. Now I am trying to re-write that program in VB10. I was able to figure out how to make everything work except for the main element, the Database controls. Is there something that I can read to learn how the new code works? Thanks, Garner
-
I pretty much figured out that everything was different when none of my code worked anymore and nothing that I did helped. That was pretty much my original question. What do I read and where do I find it? I have read stuff online for hours in forums, MSDN, sample code ...? I have looked for books on the subject but I haven't found anything that seems like it would help. In VB6 I went to the book store, picked up a book, "Visual Basic 6 Database Programming," and everything I needed was there. No such luck with VB10.
-
Now I think I’m worse off than I originally thought since I don’t even know how to answer your question. Guessing “UI” means “User Interface?” If so, I think that is where my problem is. Here’s the old VB6 code I used for my “Update” button in the user interface. VB10 highlights just about all of it with all kinds of errors. The worst part is that I have several buttons in each of several interfaces controlling several databases. “Add,” “Update,” “Delete,” & “Refresh” are the buttons that I am using.
Private Sub cmdUpdate_Click() On Error GoTo UpdateErr Dim db As Database Set db = OpenDatabase("c:\microsoft visual studio\vb98\openaccts.mdb") Dim rs As Recordset Set rs = db.OpenRecordset("prices", dbOpenDynaset) 'Edit record and show new prices. rs.Edit rs.Fields("1b") = txtFields(0) rs.Fields("2b") = txtFields(1) rs.Fields("2r") = txtFields(2) rs.Fields("3a") = txtFields(3) rs.Fields("3s") = txtFields(4) rs.Fields("as") = txtFields(5) rs.Fields("br") = txtFields(6) rs.Fields("bs") = txtFields(7) rs.Fields("fd") = txtFields(8) rs.Fields("ms") = txtFields(9) rs.Fields("os") = txtFields(10) rs.Fields("ts") = txtFields(11) rs.Fields("tu") = txtFields(12) rs.Fields("ws") = txtFields(13) rs.Update 'Change prices on PRODUCT form. frmprdm!txt1b.text = rs.Fields("1b") frmprdm!txt2b.text = rs.Fields("2b") frmprdm!txt3a.text = rs.Fields("3a") frmprdm!txt3u.text = rs.Fields("3s") frmprdm!txtas.text = rs.Fields("as") frmprdm!txtbr.text = rs.Fields("br") frmprdm!txtbs.text = rs.Fields("bs") frmprdm!txtfd.text = rs.Fields("fd") frmprdm!txtms.text = rs.Fields("ms") frmprdm!txtou.text = rs.Fields("os") frmprdm!txtts.text = rs.Fields("ts") frmprdm!txttu.text = rs.Fields("tu") frmprdm!txtws.text = rs.Fields("ws") Exit Sub UpdateErr: MsgBox Err.Description End Sub
I have read a ton of information online about changing the code and; so far, none of it has worked for me. Thanks, GarnerAs mentioned ADO.NET is different to ADO but looking at that code I would recommend you may do well to use Entity Framework. It will abstract away a lot of the implementation and should fit quite nicely with your current model. Julie Lerman has created a great beginners guide screencast. If you want to get up and running fast, I'd go straight to EF - Part 1 section. Enjoy
"You get that on the big jobs."
-
I pretty much figured out that everything was different when none of my code worked anymore and nothing that I did helped. That was pretty much my original question. What do I read and where do I find it? I have read stuff online for hours in forums, MSDN, sample code ...? I have looked for books on the subject but I haven't found anything that seems like it would help. In VB6 I went to the book store, picked up a book, "Visual Basic 6 Database Programming," and everything I needed was there. No such luck with VB10.
Here's a link to Amazon.com ADO.NET on Amazon[^] Some in the list are specific for VB. Julia Lerman's book is also mentioned and, like Rob above, I would recommend going the Entity Framework route as you then have an abstraction layer over the ADO.NET itself.
It’s not because things are difficult that we do not dare, it’s because we do not dare that things are difficult. ~Seneca
-
Here's a link to Amazon.com ADO.NET on Amazon[^] Some in the list are specific for VB. Julia Lerman's book is also mentioned and, like Rob above, I would recommend going the Entity Framework route as you then have an abstraction layer over the ADO.NET itself.
It’s not because things are difficult that we do not dare, it’s because we do not dare that things are difficult. ~Seneca