Ask the Expert

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

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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

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: