Prev: CreateObject Error 91 Object variable or With block variable not set
Next: MSDN98, MSDN Library Visual Studio 6.0a
From: Ayaz on 22 Dec 2005 16:00 Hello, i am creating a system where i add, amend and delete data from my database. i have been looking at vb6 and ado and dao. i have been told to go for ado objects such as recordsets and connection. (adodb). I have used VBA before and have managed to create a system using it. I have used my vba code to create the following program in VB6 - with slight adjustments. but it worked!! My question is: i have looked at the coding for adodb - and it does require more than what i did with the program below. what is the advantage of using adodb compared to how i coding the program below? should i code my system using the code below? - obviously i will implement error checking and validation etc. Dim dbShop As Database 'declare database object Dim rsShop As Recordset 'declare recordset object Set dbShop = OpenDatabase("shopping.mdb") 'initialiase database object Set rsShop = dbShop.OpenRecordset("Products") 'initialise recordset object rsShop.AddNew rsShop("Product") = Text1.Text rsShop("Quantity") = Text2.Text rsShop.Update rsShop.Close dbShop.Close MsgBox ("Product and Quantity sucessfully addded") Form1.Hide i was just checking whethe the code that i used for vba would work in vb6. i dont know what to do, im a little confused. stick with this method or turn to adodb objects? all i want to be able to do is add, amend, delete products, suppliers, users and so on. regards
From: MikeD on 22 Dec 2005 17:34 "Ayaz" <Ayaz(a)discussions.microsoft.com> wrote in message news:D66A22D8-9564-44EF-B9E5-7FF619C906D2(a)microsoft.com... > Hello, i am creating a system where i add, amend and delete data from my > database. i have been looking at vb6 and ado and dao. i have been told to > go > for ado objects such as recordsets and connection. (adodb). > > I have used VBA before and have managed to create a system using it. I > have > used my vba code to create the following program in VB6 - with slight > adjustments. but it worked!! > > My question is: i have looked at the coding for adodb - and it does > require > more than what i did with the program below. what is the advantage of > using > adodb compared to how i coding the program below? should i code my system > using the code below? - obviously i will implement error checking and > validation etc. > > > i was just checking whethe the code that i used for vba would work in vb6. > i > dont know what to do, im a little confused. stick with this method or turn > to > adodb objects? all i want to be able to do is add, amend, delete products, > suppliers, users and so on. Your posted code is using DAO. If your database is Access AND is going to remain Access for at least the forseeable future, I'd recommend staying with DAO. One reason is that you're apparently already somewhat familiar with it. A second reason is there's no advantage that ADO is going to give you for an Access backend database. In fact, DAO is slightly more efficient than ADO with Access databases. Now, if you might upsize your Access database to something else in the future (SQL Server, MSDE, Oracle, MySQL or whatever), then ADO would be the way to go since it will make things much easier for when you do upsize. It's very possible there would be little (and maybe no) code that you'd have to change, other than specifying a different OLEDB Provider and/or connection string. Are you even more confused now? <g> BTW, have you previously posted under the name Pinto1uk? Lot of similarities between this post and posts made by Pinto1uk. If you are the same person, then again I recommend you visit your local library or bookstore and get a decent book on database programming with VB6. -- Mike Microsoft MVP Visual Basic
From: Ayaz on 22 Dec 2005 17:56 hello mike, thank you for all your help. i have just acquired a book called introduction to database programming. will be spending some time looking through it. i am not pint1uk. "MikeD" wrote: > > "Ayaz" <Ayaz(a)discussions.microsoft.com> wrote in message > news:D66A22D8-9564-44EF-B9E5-7FF619C906D2(a)microsoft.com... > > Hello, i am creating a system where i add, amend and delete data from my > > database. i have been looking at vb6 and ado and dao. i have been told to > > go > > for ado objects such as recordsets and connection. (adodb). > > > > I have used VBA before and have managed to create a system using it. I > > have > > used my vba code to create the following program in VB6 - with slight > > adjustments. but it worked!! > > > > My question is: i have looked at the coding for adodb - and it does > > require > > more than what i did with the program below. what is the advantage of > > using > > adodb compared to how i coding the program below? should i code my system > > using the code below? - obviously i will implement error checking and > > validation etc. > > > > > > i was just checking whethe the code that i used for vba would work in vb6. > > i > > dont know what to do, im a little confused. stick with this method or turn > > to > > adodb objects? all i want to be able to do is add, amend, delete products, > > suppliers, users and so on. > > > Your posted code is using DAO. If your database is Access AND is going to > remain Access for at least the forseeable future, I'd recommend staying with > DAO. One reason is that you're apparently already somewhat familiar with it. > A second reason is there's no advantage that ADO is going to give you for an > Access backend database. In fact, DAO is slightly more efficient than ADO > with Access databases. > > Now, if you might upsize your Access database to something else in the > future (SQL Server, MSDE, Oracle, MySQL or whatever), then ADO would be the > way to go since it will make things much easier for when you do upsize. It's > very possible there would be little (and maybe no) code that you'd have to > change, other than specifying a different OLEDB Provider and/or connection > string. > > Are you even more confused now? <g> > > BTW, have you previously posted under the name Pinto1uk? Lot of > similarities between this post and posts made by Pinto1uk. If you are the > same person, then again I recommend you visit your local library or > bookstore and get a decent book on database programming with VB6. > > -- > Mike > Microsoft MVP Visual Basic > > >
From: Ivar on 22 Dec 2005 19:03 Just my opinion. If you just want to do as you say then stick with the DAO, it's faster and simpler to code, and does not need so many dependencies to install. If one day you want to print reports using the VB report designer then you wouldn't need to update your existing code, but you will need to start using the increased capabilities of the ADO. Just summink else to think about. Ivar here's another thought to ponder upon. I have built (and so have others) apps using VB6 That adds, deletes, updates, queries, sorts, lists, reports and all sorts of other things on thousands of records without using databases or anything outside the very basics of VB itself. Just another way to go :-) "Ayaz" <Ayaz(a)discussions.microsoft.com> wrote in message news:D66A22D8-9564-44EF-B9E5-7FF619C906D2(a)microsoft.com... > Hello, i am creating a system where i add, amend and delete data from my > database. i have been looking at vb6 and ado and dao. i have been told to > go > for ado objects such as recordsets and connection. (adodb). > > I have used VBA before and have managed to create a system using it. I > have > used my vba code to create the following program in VB6 - with slight > adjustments. but it worked!! > > My question is: i have looked at the coding for adodb - and it does > require > more than what i did with the program below. what is the advantage of > using > adodb compared to how i coding the program below? should i code my system > using the code below? - obviously i will implement error checking and > validation etc. > > > Dim dbShop As Database 'declare database object > Dim rsShop As Recordset 'declare recordset object > > Set dbShop = OpenDatabase("shopping.mdb") 'initialiase database object > Set rsShop = dbShop.OpenRecordset("Products") 'initialise recordset > object > > rsShop.AddNew > > rsShop("Product") = Text1.Text > rsShop("Quantity") = Text2.Text > > rsShop.Update > > rsShop.Close > dbShop.Close > > MsgBox ("Product and Quantity sucessfully addded") > > Form1.Hide > > i was just checking whethe the code that i used for vba would work in vb6. > i > dont know what to do, im a little confused. stick with this method or turn > to > adodb objects? all i want to be able to do is add, amend, delete products, > suppliers, users and so on. > > regards
From: Gman on 22 Dec 2005 19:07
Just curious: > here's another thought to ponder upon. I have built (and so have others) > apps using VB6 That adds, deletes, updates, queries, sorts, lists, reports > and all sorts of other things on thousands of records without using > databases or anything outside the very basics of VB itself. Just another way > to go :-) What did you use? XML? Flat text files? Binary files? Thanks |