Data Environment... newbie question...

  • Thread starter Thread starter José Araujo
  • Start date Start date
J

José Araujo

Hi,

Data Environment no longer exist in VB.NET, however, I am trying to
accomplish what they provided in VB 6.0.

It was a good way of having all the connection related information
centralized in one point in the program.

I was wondering if somebody could point me to the appropiate documentation,
or give a brief introduction in the subject.

Thanks,
José Araujo.

PS: i posted the question in this forum, if somebody think that there is a
better place to post it just let me know.
 
Where to put a SQL Server connection string is a little more tricky in .NET.
In a web app, I would recommend placing it in the web.config. In a windows
app, add an application config and putting it there is good.

If you're using an OLEDB source, you still have the data link as an option.
You do not have this option if you are using the SQLClient namespace.

In terms of using the connections, there's so many options now... I
recommend checking out the MSDN data design pattern.
 
José,
You can approximate a Data Environment object in .NET using a Component.

1. Use "Project - Add Component" to add a new component class to your
project.
2. Drag a Connection object onto the design surface of the Component, set
any properties.
3. Drag Command & Data Adapter objects onto the design surface, setting
properties.
4. Switch to code view to add any instance methods to encapsulate the above
objects.

Alternatively you can drag items from the Server Explorer onto the above
design surface. You can actually drag Server Explorer objects onto any
design surface (forms or user controls also).

Hope this helps
Jay
 
Thanks.

I can do that (i didn't know i could, thanks for the information)... but my
problem now is that when i try to use the property window to connect a
SqlCommand to a SqlConnection that is in another Component, it doesn't
show...

The property window only let me link SqlCommand to SqlConnections that are
created in the same form (even though the SqlConnections in other forms are
public, and i have a module which creates a public instance of my Component
Class).

I can imagine how hard it is for the property window to understand what i am
trying to accomplish. I understand the reason why my objects doesn't show up
there.

My question stills being what the recommended way of doing this is... If i
want to create a project with 20-30 data screen, i don't want to have 20-30
SqlConnections objects in my program, but i don't want to do everything
programmatily, i want to take advantage of the IDE at much as i can.

Also i just noticed that the drag&drop feature that the data environment had
does exist anymore (or at least, i can't find it).

Thanks a lot,
José Araujo.
 
José,
I do not include SqlConnections in forms, except for quick & dirty, will
this work type forms. On these quick & dirty forms, they get thrown away
almost immediately.

Think logical n-tier architecture. (where you have data, business &
presentation logical layers). Remember you can have Logical layers within a
single program, a single executable, as opposed to physical n-tier layers
across machines.

Your data access is "isolated" from your presentation.
My question stills being what the recommended way of doing this is... If i
want to create a project with 20-30 data screen, i don't want to have 20-30
SqlConnections objects in my program, but i don't want to do everything
programmatily, i want to take advantage of the IDE at much as i can.
I would have 1 data component, that has my 1 SqlConnection on it, plus 20-30
data adapters. You can use drag & drop within the IDE to build this one
component. I would manually add methods to update & fill one or more dataset
based on one or more data adapters, depending on the requirements for
handling the data.

You can then drag this one component to each form (which I would not do). Or
you can reference the single instance of this component via code (which I
would do).

If you don't have it, David Sceppa's book "Microsoft ADO.NET - Core
Reference" from MS Press covers ADO.NET in great details, including a
chapter on effective Windows based applications.

Hope this helps
Jay
 
Back
Top