Q

What is the best technique for connecting to a database from VB.NET?

This Content Component encountered an error

I have already worked with VB6, but in VB.NET there are two techniques to connect to a database:

  1. by using the old ADO connectivity technology (i.e. conn and recordset objects)
  2. by using DataSets and data adapters in ADO.NET.

Which technique is preferable, and which technique would you recommend for future purposes?
If you're porting existing VB6 code, the VB6 to VB.NET migration wizard will copy over your old ADO code and bring in the ADO COM library for interop into your VB.NET project. Depending on how much work it is to move this code forward, you may well decide to leave this code in place.

However, if you're writing new code, I recommend writing it using ADO.NET. ADO.NET was re-architected to fix real-world problems in ADO. The primary benefit of ADO.NET is its disconnected model, adding scalability to your back end. Of course, the usual benefits of writing new code in the new way are there as well, including tool and vendor support as well as lots of samples, books, articles, etc. The downside of writing the same old code in a new way is that you'll have to learn the new way, but since I think that everything you learn makes learning new things that much easier, I consider that an upside of moving to ADO.NET.

This was first published in January 2003

Dig deeper on Win Development Resources

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close