ADO.NET with Visual Basic .NET

Posted March 22, 2004

Chat Date: March 2, 2004

Please note: Portions of this transcript have been edited for clarity

Introduction

Moderator: Ed_H (Microsoft)
Welcome to today’s chat on ADO.NET with Visual Basic .NET. We have members of the Visual Basic team here to answer your questions today. I will ask the hosts to introduce themselves.

Host: DavidSc (Microsoft)
My name is David Sceppa and I work on the WebData team, focusing on technologies data access technologies like ADO.NET. I'm also the author of Microsoft ADO.NET from Microsoft Press.

Host: Eric (Microsoft)
Hi! I'm Eric Gruber a Software Design Engineer in Test on the Visual Basic team.

Host: Hussein (Microsoft)
Hi, my name is Hussein Abuthuraya. I'm currently Support Professional with PSS

Host: Hussein (Microsoft)
WebData team supporting Data Access technologies in .NET and unmanaged applications.

Host: SteveLas (Microsoft)
Hi, I’m Steve Lasker. I’m a program manager on the Visual Basic team responsible for Data DesignTime features including the Typed DataSet Designer and DataAdapter Configuration Wizards.

Host: SteveS (Microsoft)
Hi All - I'm Steve Stein a Programmer/Writer on the VB Team.

Moderator: Ed_H (Microsoft)
And I am Ed Hickey, VS Communities PM. Glad you all could make it today!

Moderator: Ed_H (Microsoft)
Let's get started! Fire away with your questions for our hosts.

Start of Chat.

Host: Hussein (Microsoft)
Q: BallyDev : Is there any memory leak associated with ADO.NET connections
A: In general there are no memory leaks with ADO.NET connections but there was a known connections leak with OracleClient and ASP

Host: Hussein (Microsoft)
See article FIX: Connection Leak with .NET Data Provider for Oracle in ASP.NET (https://support.microsoft.com/?id=330126)

Host: DavidSc (Microsoft)
Q: What book would you recommend for someone that is just getting started with this?
A: I'll shamelessly plug my own book, "Microsoft ADO.NET" from Microsoft Press. But Rebecca Riordan, William Vaughn, Bob Beauchemin, and Shawn Wildermuth have all written strong books on the subject.

Host: SteveLas (Microsoft)
Joe: You might try inheriting from the typed dataTable then merging. It's possible the dataTable you’re referencing doesn't have the schema loaded.
Q: What is the best way in code to bind controls to a DataSet that I created in code? A: Ben is correct in saying that Control.DataBindings.Add is the simplest way to bind a TextBox to a column in a DataTable.

Host: DavidSc (Microsoft)
There are other options depending on the control you're using (textbox, datagrid, combo, etc.) and the type of data you're looking to display (contents of a DataTable, filtered contents through a DataView, related rows through a DataRelation.

Host: DavidSc (Microsoft)
If you provide a little more information on what control you're using, and what data you want to display, we could provide a more precise answer.

Host: SteveS (Microsoft)
Q: Pretty simple question, but if in a multiuser MSSQL-based winforms app, each user loads tables into a dataset on separate PCs, do I have to manually call update all the time to get changes?
A: You need to manually call DataAdapter.Fill to bring current data onto one of the PC's. If you setup the adapter for concurrency checking calling update will throw an exception only if the data in the db changed since your last fill.

Host: Eric (Microsoft)
Q: Why aren't my typed properties being merged into an untyped dataset?
A: For typed properties which you add to a DataTable, you need to add a corresponding DataColumn to the base typed DataTable. When you call Merge or Clone, the base DataColumns are used - not the typed properties which you added to the base class.

Host: SteveLas (Microsoft)
Joe: When merging two datasets, we merge the data within the DataTables, I think the source of the problem is you're looking to merge the schema. Both tables must have the same Schema, (Columns) for the data to be merged.

Host: DavidSc (Microsoft)
Q: For ADO.NET using SQL Server, is the best approach to concurrency still to check a timestamp?
A: The answer depends on how you want to perform your concurrency checks.

Host: DavidSc (Microsoft)
If you want your update attempts to fail if another user has changed the value of any other column, including columns you didn't update or query, using timestamps can greatly simplify your updating logic.

Host: DavidSc (Microsoft)
Keep in mind that if you successfully update the row, you'll need to re-query the row to determine the new timestamp value if you want to submit subsequent updates against the row.

Host: SteveS (Microsoft)
Q: No, I mean doesn't the DataAdapter check every field when it does an update, if you don't customize it?
A: Yes, if you select the 'Use optimistic concurrency' option in the Data Adapter Wizard the default is to check all (non blob) columns.

Host: SteveLas (Microsoft)
Q: What's the best approach for creating DataSets in an MDI Windows Forms?

Host: SteveLas (Microsoft)
central DataSet referenced by all forms or one DataSet per Form?A: There's no best answer. By sharing one common DataSet you can reduce the amount of memory loaded on the client, and share data between forms easily. However, that means that all forms need to share data. Many people use one DataSet for all their Lookup Data, like list of States, and individual DataSets for each form.

Host: SteveS (Microsoft)
Q: Hi, anybody can tell me how to delete a row in the windows.forms.datagrid?
A: Other than clicking the delete button :) you can also do it programmatically. Check out these article:

Host: SteveS (Microsoft)
Deleting Records in a Dataset (Visual Basic and Visual C# Concepts) https://msdn.microsoft.com/library/en-us/vbcon/html/vbtskdeletingrecordsindataset.asp

Host: DavidSc (Microsoft)
Q: I thought that concurrency optimistic is default? what is special with blobs?
A: BLOBS cannot be compared to determine if they've changed. So, you should leave them out of the WHERE clause of an UPDATE or DELETE query. The DataAdapter Configuration Wizard is aware of this, and leaves BLOB columns out of concurrency checks.

Host: SteveLas (Microsoft)
Q: Is For doing aggregate functions on a dataTable on the client side, use dataTable.Compute(...) instead of going back to the db!A: If your calculation is static, such as the amount of rows you can pull it down from the server. If your calculation is dynamic, and you’re looking to show the sum of values as the user makes changes, compute would work well.

Host: SteveS (Microsoft)
Q: Hi SteveS I never could find that delete button (I know how to do it programmatically, would be great if you would tell me I always thought should be there and could until now never find it?)
A: There is no actual Delete button on the grid. The links I gave above explain how to programmatically locate the selected row in a datagrid, and how to delete the selected row in the dataset.

Host: DavidSc (Microsoft)
Q: How can I determ if by instance is refreshed by another user in the mean time while editing a picture?
A: You can't check the contents of the picture to see if it has changed, but if you've already retrieved the timestamp value for the row you can query the database to see if another user has modified the row.

Host: Eric (Microsoft)
Q: Is there any way to prevent the users to add new rows, but they can change the existing data?
A: If you are binding to a DataView, you can set the AllowNew property of the DataView to False. Users can still change data but can't add new rows.

Moderator: Ed_H (Microsoft)
This has been a GREAT chat. Thank you to everyone. Unfortunately, it is time to go. Thanks for participating, and we'll see you next time!

Moderator: Ed_H (Microsoft)
Please join us next week for the chat on Using Windows Forms Controls in Visual Basic .NET

For further information on this topic please visit the following:

Newsgroups: microsoft.public.dotnet.languages.vb

VB .NET Transcripts: Read the archive of past VB .NET chats.

Website: Visit the Microsoft Visual Basic .NET site.

Top of PageTop of Page