다음을 통해 공유


ADO.NET with Visual Basic .NET

Posted November 3, 2004

Chat Date: October 26, 2004

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

Introduction

Ed_H_MS (Moderator):
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.

DavidSc_MS (Expert):
Hello! My name is David Sceppa. I'm a Program Manager on the team responsible for the data access API. I'm also the author of "Microsoft ADO.NET" available from Microsoft Press.

SteveLas_MS (Expert):
Hi, I'm Steve Lasker. I'm a Program Manager responsible for Data Designtime features such as the Data Sources Window, Typed DataSet Designer and Data Configuration Wizards.

SteveS_MS (Expert):
Hi all - I'm Steve Stein, a programmer/writer on the Visual Basic team.

Ed_H_MS (Moderator):
And I am Ed Hickey, Visual Basic MVP Lead. Glad you all could make it today!

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

Start of Chat

SteveLas_MS (Expert):
Q:
I know how to setup a sql connection in asp.net while working locally. what should I change and how can I configure my sql connection when moving the files to the host's server?
A: The ConnectionString is stored in Web.config by default. You can edit the Web.config, or create a separate Web.config for your production server.

DavidSc_MS (Expert):
Q:
How do you select a type of guid in the for an element in the dataset.xsd designer in VS.2003
A: The DataSet designer didn't list a data type that appeared to map to Guid. I created a SQL Server table with the uniqueidentifier data type (which does map to Guid), then dragged and dropped that table to the DataSet designer. I instantiated the typed DataSet and the data type for the column was Guid, though the designer still said it was a string. Long story short, it looks like your best bet is to create the DataSet's schema that way.

SteveLas_MS (Expert):
Q:
How do you select a type of guid in the for a element in the dataset.xsd designer in VS.2003
A: In VS2005 we do now show the Guid as a DataType for the Column

SteveLas_MS (Expert):
Hank, can you post your followup question using the Question Manager?

SteveLas_MS (Expert):
Q:
When writing applications in disconnected mode, before the user goes off-line he must download the whole database from SQL and save it to an XML Dataset ? and have to do this each time he goes off-line?
A: While the DataSet can be persisted to disk and used for offline storage, it's not meant to be a real database, and has practical limitations for the amount of data. Depending on what you're trying to accomplish, MSDE might be a better approach. Is this the question you're asking?

SteveLas_MS (Expert):
Q:
So I must try to keep the data volume as low as possible when is disconnected ?
A: I wouldn't say you must keep the volume of data low per se. I'm suggesting that if you really need an offline persistent storage engine, then MSDE is a better choice. If you’re trying to cache smaller elements of data, such as a list of States or Codes, then local DataSets persisted to disk work well.

SteveLas_MS (Expert):
Q:
ok, I got it, and so the disconnected application, when comes connected again, do a replication with the master db. Is it right?
A: Yes. MSDE has a good replication model that can be used to help push data back and fourth. It can be a little heavy weight for some people as they learn the replication tools, but they are very powerful. They will continue to get much easier as we make further enhancements with SQL Server 2005 and SQL Express.

NicholasPaldino_MVP (Expert):
Q:
For example, I might want to run a stored procedure, but take care of the connection management myself.

SteveLas_MS (Expert):
Q:
Another question: When modifying a record on a form, using DataBindings, the fields are filled with spaces. Is there any way to apply something like the "Trim" function to avoid these spaces, with the databindings?
A: There are formatting events that exist on the controls and DataBinding. Let me see if I can dig up a sample.

SteveS_MS (Expert):
Q:
Another question: When modifying a record on a form, using DataBindings, the fields are filled with spaces. Is there any way to apply something like the "Trim" function to avoid these spaces, with the databindings?
A: These topics have examples:

DavidSc_MS (Expert):
Richard: With less data, I'm seeing a slightly higher perf hit, about 25%. I don't have a simple explanation for the perf hit, but I do believe that nesting the relational data does make both the read and write processes a little more complex.

SteveS_MS (Expert):
A:
Format event lets you change the data before it displays in the bound control, and the parse event lets you take the data in the control and change it as you send it back to the db:

Binding.Format

ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfSystemWindowsFormsBindingClassFormatTopic.htm

Binding.Parse

ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfSystemWindowsFormsBindingClassParseTopic.htm

NicholasPaldino_MVP (Expert):
Q:
Another question: When modifying a record on a form, using DataBindings, the fields are filled with spaces. Is there any way to apply something like the "Trim" function to avoid these spaces, with the databindings?

SteveLas_MS (Expert):
Q:
While I think the data story in VS.NET 2005 has gotten much better, I do wonder why you make it so hard to assign connections to the managed wrappers that the designer creates. I should never have to modify designer code.
A: In Beta 2 the TableAdapter.Connection property will have a Modifier associated with it. Developers will be able to change the Connection property to Public if they'd like. We initially received a lot of feedback that we should keep the internals of the TableAdapter private, (don't let your friends see you privates).

DavidSc_MS (Expert):
Q:
I defined a dataset using the XSD Designer in Visual Studio 2003. The resulting dataset has a parent plus two child tables, along with two relationships. In order to get the Dataset object to save the data in a nested XML file, I also needed to nest the
A: The DataRelation's Nested property is the way to control that portion of the format of the XML representation of the data. Based on your results and the simple tests I just ran, it does appear that there's a perf hit to load data from this format. You could try saving the data in the non-nested (default) format from the DataSet and use an XSL transform to get the data in the desired format.

SteveLas_MS (Expert):
Q:
That's a good solution, flexible. I assume the default is private, but it's not as big of a price to pay compared to modifying designer code.
A: Thanks. This was based on feedback from B1. Another thing to note is VS 2005 will leverage partial classes to give developers their own "sandbox". Rather then having to modify the generated code, we'll create a separate file for developers to extend the Typed DataSet. We'll generate a NorthwindDataSet.designer.vb file. This is the result of the Custom Tool. If you double click in the designer (only works for VB in B1), we'll generate a NorthwindDataSet.vb file that is your file. We'll never clobber over your code.

SteveLas_MS (Expert):
Q:
I am curious, are we going to see the evolution of the data access into data layers? It's an out there question. Something that would handle the persistence for us, the auditing, the security, etc, etc. ObjectSpaces is a step in this direction (although I don't want to encapsulate my data), but it's not grand enough, IMO.
A: There are a number of efforts going on to solve this space. One of which is the MBF work that's available for 2003. We've also done some work in Whidbey to make it easier to work with objects that contain data using our Design Time Object Binding. Our TableAdapters will play a role in dealing with the CRUD of persisting the data from your own objects. For the big question of what's an overall, inclusive, extensible solution, we're working on incorporating elements from several solutions we've been working on and/or have shipped in the past. This includes the FoxPro syntax model, elements from Object Spaces, and some other research projects.

SteveLas_MS (Expert):
Q:
What about having the typed data set extend from another base class (that derives from DataSet). Is there any support for that? For example, I might always want my data set to serialize using the new binary format, and have some helper functions on it.
A: We don't support you changing the DataSet base class, but we do support changing the TableAdapter base class. As long as it derives from Component.

SteveLas_MS (Expert):
We also added Binary Formatting to DataSet

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

NicholasPaldino_MVP (Expert):
SteveLas_MS: I'm not so concerned about the TableAdapter, because chances are in an enterprise space, I am going to be rolling my own generic data adapter of some sort. What I need is to have the data set perform some operations when created, etc, etc, capture client context...

SteveS_MS (Expert):
Thanks All!

DavidSc_MS (Expert):
Thanks, everyone!

SteveLas_MS (Expert):
Take care all.

Top of pageTop of page