Thursday, March 29, 2012

Object Null Reference Exception (vb)

Can someone tell me what this compiler error means?
Using VS.NET 2002/VB

----------------
Dim objFIF As New RMClassLib.FtInFr()

objFIF.CreateNewFIF(False, False, 3, 24)

pitchInDrp.DataSource = objFIF.GetNewFIF

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Line 133: Dim objFIF As New RMClassLib.FtInFr()
-----------------

Thanks,
GeorgeIgnore that request for help. I think I have it figured out.

Thanks.
George

"George" <--@.--.--> wrote in message
news:4L0Sb.30723$6O4.823971@.bgtnsc04-news.ops.worldnet.att.net...
> Can someone tell me what this compiler error means?
> Using VS.NET 2002/VB
> ----------------
> Dim objFIF As New RMClassLib.FtInFr()
> objFIF.CreateNewFIF(False, False, 3, 24)
> pitchInDrp.DataSource = objFIF.GetNewFIF
> Exception Details: System.NullReferenceException: Object reference not set
> to an instance of an object.
> Line 133: Dim objFIF As New RMClassLib.FtInFr()
> -----------------
> Thanks,
> George

Object Oriented / App Design Question

I am designing a web application in asp.net C#, and I created classes (in
.cs files) working with the .aspx pages. Now, for database part...
wondering which way is better:
1. put database connectivity in the Classes, each class has the load/save
data method? Many of my classes are inherited from each other, and since I
am using SQL 2000 which is a relational database makes the job little bit
more complicated.
2. put database connectivity in .aspx pages, then get/put the data from/into
the classes when needed? This sounds easier, but is it a bad design?
Any suggestions are welcome.. thanksOOAD normally involves slightly more work but has great deal of advantages
in terms of breaking the system down into manageable chunks.
Consider a page where you have user login, registration, profile view and
edit etc. They all related to all users and potentially have independant UI.
So you would have say 4 aspx pages with code behind. But to directly access
the database from those codebehind classes doesnt help code reuse like if
you needed the same data somewhere else.. in that case you would be
repeating the code. So you create a Middletier which essentially channels
call. So all you aspx pages would do is call the middle tier class to get
the data..
The middle tier classes could implement the logic to connect to the database
and fetch the data which you return to the calling function. that way your
aspx page is not way concerned on whether you are using access or sql server
or msde or oracle or sybase. You could go further and use generic data
access block like the one from MS which lets you connect and do queries on
ms sql 7 or above. That way if you change the database all you have to
change is the middle-tier and replace the calls with new library class..
ASPX ==> codebehind for presentation logic >> Middle tier >> Data Access
Tier >> Database. Read up a bit on layed / tiered application design..
Regards,
Hermit Dave
(http://hdave.blogspot.com)
"NOSPAM" <nospam@.xsagfgsagsafg.com> wrote in message
news:OsCdnXI8-P3i_cncRVn-tA@.rogers.com...
> I am designing a web application in asp.net C#, and I created classes (in
> .cs files) working with the .aspx pages. Now, for database part...
> wondering which way is better:
> 1. put database connectivity in the Classes, each class has the load/save
> data method? Many of my classes are inherited from each other, and since I
> am using SQL 2000 which is a relational database makes the job little bit
> more complicated.
> 2. put database connectivity in .aspx pages, then get/put the data
from/into
> the classes when needed? This sounds easier, but is it a bad design?
> Any suggestions are welcome.. thanks
>
>
I am not sure I like either. One methodology that works well is the creation
of a persistance layer that controls marshalling the business objects from
the database to your app. You have methods in the class that force the
callback, but the object-relation mapping engine (persistence layer part) is
actually aware of how to get the data back. This is a better OO design, and
you can find examples on open source sites like SourceForge (including
code).
Rockford Lhotka has his own design of a data "persistance" type of engine
that looks promising. It is in both his VB.NET and C# objects books. You can
download the code and adopt it for your site.
Finally, ObjectSpaces will be out in a future Visual Studio. It allows
mapping via an XML Schema. Unfortunately, it has been dumped from Whidbey
timeframe, but you can still get the March preview and play around with the
idea. If you can get a similar method, you will be ready when objectspaces
are finally available.
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
****************************************
*********
Think outside the box!
****************************************
*********
"NOSPAM" <nospam@.xsagfgsagsafg.com> wrote in message
news:OsCdnXI8-P3i_cncRVn-tA@.rogers.com...
>I am designing a web application in asp.net C#, and I created classes (in
> .cs files) working with the .aspx pages. Now, for database part...
> wondering which way is better:
> 1. put database connectivity in the Classes, each class has the load/save
> data method? Many of my classes are inherited from each other, and since I
> am using SQL 2000 which is a relational database makes the job little bit
> more complicated.
> 2. put database connectivity in .aspx pages, then get/put the data
> from/into
> the classes when needed? This sounds easier, but is it a bad design?
> Any suggestions are welcome.. thanks
>
>
Does that mean option (1) is better? To be specific, the Classes I wrote
can be act as middle tier, and they all get compiled as .dll put in the
/bin.
"Hermit Dave" <hermitd.REMOVE@.CAPS.AND.DOTS.hotmail.com> wrote in message
news:%23iXugImoEHA.1776@.TK2MSFTNGP14.phx.gbl...
> OOAD normally involves slightly more work but has great deal of advantages
> in terms of breaking the system down into manageable chunks.
> Consider a page where you have user login, registration, profile view and
> edit etc. They all related to all users and potentially have independant
UI.
> So you would have say 4 aspx pages with code behind. But to directly
access
> the database from those codebehind classes doesnt help code reuse like if
> you needed the same data somewhere else.. in that case you would be
> repeating the code. So you create a Middletier which essentially channels
> call. So all you aspx pages would do is call the middle tier class to get
> the data..
> The middle tier classes could implement the logic to connect to the
database
> and fetch the data which you return to the calling function. that way your
> aspx page is not way concerned on whether you are using access or sql
server
> or msde or oracle or sybase. You could go further and use generic data
> access block like the one from MS which lets you connect and do queries on
> ms sql 7 or above. That way if you change the database all you have to
> change is the middle-tier and replace the calls with new library class..
> ASPX ==> codebehind for presentation logic >> Middle tier >> Data Access
> Tier >> Database. Read up a bit on layed / tiered application design..
> --
> Regards,
> Hermit Dave
> (http://hdave.blogspot.com)
> "NOSPAM" <nospam@.xsagfgsagsafg.com> wrote in message
> news:OsCdnXI8-P3i_cncRVn-tA@.rogers.com...
(in
load/save
I
bit
> from/into
>
well there are lots of techniques and all have their advantages and
divantages. What you use is based on
a. how much seperation you want
b. the hassle you wouldnt mind going into.
I would say that option 1 isnt bad... though you could still drill further
down to increase the seperation.
consider thing.. from every class that access database you will start by
getting the connection string and creating a connection etc. You break that
down further but you have to decide on factors A & B.
You want to look up on what Greg mentioned as well..
Regards,
Hermit Dave
(http://hdave.blogspot.com)
"NOSPAM" <nospam@.xsagfgsagsafg.com> wrote in message
news:o-mdnbvzwqv89cncRVn-qQ@.rogers.com...
> Does that mean option (1) is better? To be specific, the Classes I wrote
> can be act as middle tier, and they all get compiled as .dll put in the
> /bin.
>
> "Hermit Dave" <hermitd.REMOVE@.CAPS.AND.DOTS.hotmail.com> wrote in message
> news:%23iXugImoEHA.1776@.TK2MSFTNGP14.phx.gbl...
advantages
and
> UI.
> access
if
channels
get
> database
your
> server
on
> (in
> load/save
since
> I
> bit
>
Is this the book I should read?
http://www.amazon.com/exec/obidos/t...=gla
nce
I am going to buy if this is the one... Thanks a lot.
"Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@.comcast.netNoSpamM> wrote in
message news:eFgtCKmoEHA.2140@.TK2MSFTNGP11.phx.gbl...
> I am not sure I like either. One methodology that works well is the
creation
> of a persistance layer that controls marshalling the business objects from
> the database to your app. You have methods in the class that force the
> callback, but the object-relation mapping engine (persistence layer part)
is
> actually aware of how to get the data back. This is a better OO design,
and
> you can find examples on open source sites like SourceForge (including
> code).
> Rockford Lhotka has his own design of a data "persistance" type of engine
> that looks promising. It is in both his VB.NET and C# objects books. You
can
> download the code and adopt it for your site.
> Finally, ObjectSpaces will be out in a future Visual Studio. It allows
> mapping via an XML Schema. Unfortunately, it has been dumped from Whidbey
> timeframe, but you can still get the March preview and play around with
the
> idea. If you can get a similar method, you will be ready when objectspaces
> are finally available.
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
> ****************************************
*********
> Think outside the box!
> ****************************************
*********
> "NOSPAM" <nospam@.xsagfgsagsafg.com> wrote in message
> news:OsCdnXI8-P3i_cncRVn-tA@.rogers.com...
load/save
I
bit
>
Hi,
This is a fantastic read and it is free:
http://msdn.microsoft.com/architect...ns/html/Esp.asp
There are also many other patterns and practices that you will benefit from
reading. Understanding these will give you most of the design information
you will need for creating powerful applications. Good luck! Ken.
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
"NOSPAM" <nospam@.xsagfgsagsafg.com> wrote in message
news:6d6dnSCkfaiQ6cncRVn-pg@.rogers.com...
> Is this the book I should read?
>
http://www.amazon.com/exec/obidos/t...738524?v=glance[color
=darkred]
> I am going to buy if this is the one... Thanks a lot.
>
>
> "Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@.comcast.netNoSpamM> wrote in
> message news:eFgtCKmoEHA.2140@.TK2MSFTNGP11.phx.gbl...
> creation
from
part)
> is
> and
engine
> can
Whidbey
> the
objectspaces
(in
> load/save
since
> I
> bit
>
I use Rocky's CLSA framework in a large ASP.Net.
It works great. The book is one of the best "reads" out there.
There is a whole Users forum available for discussing how to implement CSLA.
http://groups.msn.com/CSLANET/messages.msnw
Petar Kozul has added some *amazing* extensions to the framework with his
ActiveObjects.
http://csla.kozul.info/
--
Joe Fallon
"NOSPAM" <nospam@.xsagfgsagsafg.com> wrote in message
news:6d6dnSCkfaiQ6cncRVn-pg@.rogers.com...
> Is this the book I should read?
> http://www.amazon.com/exec/obidos/t...=g
lance
> I am going to buy if this is the one... Thanks a lot.
>
>
> "Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@.comcast.netNoSpamM> wrote in
> message news:eFgtCKmoEHA.2140@.TK2MSFTNGP11.phx.gbl...
> creation
> is
> and
> can
> the
> load/save
> I
> bit
>

Object Oriented / App Design Question

I am designing a web application in asp.net C#, and I created classes (in
..cs files) working with the .aspx pages. Now, for database part...
wondering which way is better:

1. put database connectivity in the Classes, each class has the load/save
data method? Many of my classes are inherited from each other, and since I
am using SQL 2000 which is a relational database makes the job little bit
more complicated.

2. put database connectivity in .aspx pages, then get/put the data from/into
the classes when needed? This sounds easier, but is it a bad design?

Any suggestions are welcome.. thanksOOAD normally involves slightly more work but has great deal of advantages
in terms of breaking the system down into manageable chunks.

Consider a page where you have user login, registration, profile view and
edit etc. They all related to all users and potentially have independant UI.
So you would have say 4 aspx pages with code behind. But to directly access
the database from those codebehind classes doesnt help code reuse like if
you needed the same data somewhere else.. in that case you would be
repeating the code. So you create a Middletier which essentially channels
call. So all you aspx pages would do is call the middle tier class to get
the data..

The middle tier classes could implement the logic to connect to the database
and fetch the data which you return to the calling function. that way your
aspx page is not way concerned on whether you are using access or sql server
or msde or oracle or sybase. You could go further and use generic data
access block like the one from MS which lets you connect and do queries on
ms sql 7 or above. That way if you change the database all you have to
change is the middle-tier and replace the calls with new library class..

ASPX ==> codebehind for presentation logic >> Middle tier >> Data Access
Tier >> Database. Read up a bit on layed / tiered application design..

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"NOSPAM" <nospam@.xsagfgsagsafg.com> wrote in message
news:OsCdnXI8-P3i_cncRVn-tA@.rogers.com...
> I am designing a web application in asp.net C#, and I created classes (in
> .cs files) working with the .aspx pages. Now, for database part...
> wondering which way is better:
> 1. put database connectivity in the Classes, each class has the load/save
> data method? Many of my classes are inherited from each other, and since I
> am using SQL 2000 which is a relational database makes the job little bit
> more complicated.
> 2. put database connectivity in .aspx pages, then get/put the data
from/into
> the classes when needed? This sounds easier, but is it a bad design?
> Any suggestions are welcome.. thanks
I am not sure I like either. One methodology that works well is the creation
of a persistance layer that controls marshalling the business objects from
the database to your app. You have methods in the class that force the
callback, but the object-relation mapping engine (persistence layer part) is
actually aware of how to get the data back. This is a better OO design, and
you can find examples on open source sites like SourceForge (including
code).

Rockford Lhotka has his own design of a data "persistance" type of engine
that looks promising. It is in both his VB.NET and C# objects books. You can
download the code and adopt it for your site.

Finally, ObjectSpaces will be out in a future Visual Studio. It allows
mapping via an XML Schema. Unfortunately, it has been dumped from Whidbey
timeframe, but you can still get the March preview and play around with the
idea. If you can get a similar method, you will be ready when objectspaces
are finally available.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside the box!
*************************************************
"NOSPAM" <nospam@.xsagfgsagsafg.com> wrote in message
news:OsCdnXI8-P3i_cncRVn-tA@.rogers.com...
>I am designing a web application in asp.net C#, and I created classes (in
> .cs files) working with the .aspx pages. Now, for database part...
> wondering which way is better:
> 1. put database connectivity in the Classes, each class has the load/save
> data method? Many of my classes are inherited from each other, and since I
> am using SQL 2000 which is a relational database makes the job little bit
> more complicated.
> 2. put database connectivity in .aspx pages, then get/put the data
> from/into
> the classes when needed? This sounds easier, but is it a bad design?
> Any suggestions are welcome.. thanks
Does that mean option (1) is better? To be specific, the Classes I wrote
can be act as middle tier, and they all get compiled as .dll put in the
/bin.

"Hermit Dave" <hermitd.REMOVE@.CAPS.AND.DOTS.hotmail.com> wrote in message
news:%23iXugImoEHA.1776@.TK2MSFTNGP14.phx.gbl...
> OOAD normally involves slightly more work but has great deal of advantages
> in terms of breaking the system down into manageable chunks.
> Consider a page where you have user login, registration, profile view and
> edit etc. They all related to all users and potentially have independant
UI.
> So you would have say 4 aspx pages with code behind. But to directly
access
> the database from those codebehind classes doesnt help code reuse like if
> you needed the same data somewhere else.. in that case you would be
> repeating the code. So you create a Middletier which essentially channels
> call. So all you aspx pages would do is call the middle tier class to get
> the data..
> The middle tier classes could implement the logic to connect to the
database
> and fetch the data which you return to the calling function. that way your
> aspx page is not way concerned on whether you are using access or sql
server
> or msde or oracle or sybase. You could go further and use generic data
> access block like the one from MS which lets you connect and do queries on
> ms sql 7 or above. That way if you change the database all you have to
> change is the middle-tier and replace the calls with new library class..
> ASPX ==> codebehind for presentation logic >> Middle tier >> Data Access
> Tier >> Database. Read up a bit on layed / tiered application design..
> --
> Regards,
> Hermit Dave
> (http://hdave.blogspot.com)
> "NOSPAM" <nospam@.xsagfgsagsafg.com> wrote in message
> news:OsCdnXI8-P3i_cncRVn-tA@.rogers.com...
> > I am designing a web application in asp.net C#, and I created classes
(in
> > .cs files) working with the .aspx pages. Now, for database part...
> > wondering which way is better:
> > 1. put database connectivity in the Classes, each class has the
load/save
> > data method? Many of my classes are inherited from each other, and since
I
> > am using SQL 2000 which is a relational database makes the job little
bit
> > more complicated.
> > 2. put database connectivity in .aspx pages, then get/put the data
> from/into
> > the classes when needed? This sounds easier, but is it a bad design?
> > Any suggestions are welcome.. thanks
well there are lots of techniques and all have their advantages and
disadvantages. What you use is based on
a. how much seperation you want
b. the hassle you wouldnt mind going into.

I would say that option 1 isnt bad... though you could still drill further
down to increase the seperation.

consider thing.. from every class that access database you will start by
getting the connection string and creating a connection etc. You break that
down further but you have to decide on factors A & B.

You want to look up on what Greg mentioned as well..

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"NOSPAM" <nospam@.xsagfgsagsafg.com> wrote in message
news:o-mdnbvzwqv89cncRVn-qQ@.rogers.com...
> Does that mean option (1) is better? To be specific, the Classes I wrote
> can be act as middle tier, and they all get compiled as .dll put in the
> /bin.
>
> "Hermit Dave" <hermitd.REMOVE@.CAPS.AND.DOTS.hotmail.com> wrote in message
> news:%23iXugImoEHA.1776@.TK2MSFTNGP14.phx.gbl...
> > OOAD normally involves slightly more work but has great deal of
advantages
> > in terms of breaking the system down into manageable chunks.
> > Consider a page where you have user login, registration, profile view
and
> > edit etc. They all related to all users and potentially have independant
> UI.
> > So you would have say 4 aspx pages with code behind. But to directly
> access
> > the database from those codebehind classes doesnt help code reuse like
if
> > you needed the same data somewhere else.. in that case you would be
> > repeating the code. So you create a Middletier which essentially
channels
> > call. So all you aspx pages would do is call the middle tier class to
get
> > the data..
> > The middle tier classes could implement the logic to connect to the
> database
> > and fetch the data which you return to the calling function. that way
your
> > aspx page is not way concerned on whether you are using access or sql
> server
> > or msde or oracle or sybase. You could go further and use generic data
> > access block like the one from MS which lets you connect and do queries
on
> > ms sql 7 or above. That way if you change the database all you have to
> > change is the middle-tier and replace the calls with new library class..
> > ASPX ==> codebehind for presentation logic >> Middle tier >> Data Access
> > Tier >> Database. Read up a bit on layed / tiered application design..
> > --
> > Regards,
> > Hermit Dave
> > (http://hdave.blogspot.com)
> > "NOSPAM" <nospam@.xsagfgsagsafg.com> wrote in message
> > news:OsCdnXI8-P3i_cncRVn-tA@.rogers.com...
> > > I am designing a web application in asp.net C#, and I created classes
> (in
> > > .cs files) working with the .aspx pages. Now, for database part...
> > > wondering which way is better:
> > > > 1. put database connectivity in the Classes, each class has the
> load/save
> > > data method? Many of my classes are inherited from each other, and
since
> I
> > > am using SQL 2000 which is a relational database makes the job little
> bit
> > > more complicated.
> > > > 2. put database connectivity in .aspx pages, then get/put the data
> > from/into
> > > the classes when needed? This sounds easier, but is it a bad design?
> > > > Any suggestions are welcome.. thanks
> > >
Is this the book I should read?

http://www.amazon.com/exec/obidos/t...738524?v=glance

I am going to buy if this is the one... Thanks a lot.

"Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@.comcast.netNoSpamM> wrote in
message news:eFgtCKmoEHA.2140@.TK2MSFTNGP11.phx.gbl...
> I am not sure I like either. One methodology that works well is the
creation
> of a persistance layer that controls marshalling the business objects from
> the database to your app. You have methods in the class that force the
> callback, but the object-relation mapping engine (persistence layer part)
is
> actually aware of how to get the data back. This is a better OO design,
and
> you can find examples on open source sites like SourceForge (including
> code).
> Rockford Lhotka has his own design of a data "persistance" type of engine
> that looks promising. It is in both his VB.NET and C# objects books. You
can
> download the code and adopt it for your site.
> Finally, ObjectSpaces will be out in a future Visual Studio. It allows
> mapping via an XML Schema. Unfortunately, it has been dumped from Whidbey
> timeframe, but you can still get the March preview and play around with
the
> idea. If you can get a similar method, you will be ready when objectspaces
> are finally available.
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
> *************************************************
> Think outside the box!
> *************************************************
> "NOSPAM" <nospam@.xsagfgsagsafg.com> wrote in message
> news:OsCdnXI8-P3i_cncRVn-tA@.rogers.com...
> >I am designing a web application in asp.net C#, and I created classes (in
> > .cs files) working with the .aspx pages. Now, for database part...
> > wondering which way is better:
> > 1. put database connectivity in the Classes, each class has the
load/save
> > data method? Many of my classes are inherited from each other, and since
I
> > am using SQL 2000 which is a relational database makes the job little
bit
> > more complicated.
> > 2. put database connectivity in .aspx pages, then get/put the data
> > from/into
> > the classes when needed? This sounds easier, but is it a bad design?
> > Any suggestions are welcome.. thanks
Hi,

This is a fantastic read and it is free:
http://msdn.microsoft.com/architect...ns/html/Esp.asp

There are also many other patterns and practices that you will benefit from
reading. Understanding these will give you most of the design information
you will need for creating powerful applications. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight

"NOSPAM" <nospam@.xsagfgsagsafg.com> wrote in message
news:6d6dnSCkfaiQ6cncRVn-pg@.rogers.com...
> Is this the book I should read?
>
http://www.amazon.com/exec/obidos/t...738524?v=glance
> I am going to buy if this is the one... Thanks a lot.
>
>
> "Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@.comcast.netNoSpamM> wrote in
> message news:eFgtCKmoEHA.2140@.TK2MSFTNGP11.phx.gbl...
> > I am not sure I like either. One methodology that works well is the
> creation
> > of a persistance layer that controls marshalling the business objects
from
> > the database to your app. You have methods in the class that force the
> > callback, but the object-relation mapping engine (persistence layer
part)
> is
> > actually aware of how to get the data back. This is a better OO design,
> and
> > you can find examples on open source sites like SourceForge (including
> > code).
> > Rockford Lhotka has his own design of a data "persistance" type of
engine
> > that looks promising. It is in both his VB.NET and C# objects books. You
> can
> > download the code and adopt it for your site.
> > Finally, ObjectSpaces will be out in a future Visual Studio. It allows
> > mapping via an XML Schema. Unfortunately, it has been dumped from
Whidbey
> > timeframe, but you can still get the March preview and play around with
> the
> > idea. If you can get a similar method, you will be ready when
objectspaces
> > are finally available.
> > --
> > Gregory A. Beamer
> > MVP; MCP: +I, SE, SD, DBA
> > *************************************************
> > Think outside the box!
> > *************************************************
> > "NOSPAM" <nospam@.xsagfgsagsafg.com> wrote in message
> > news:OsCdnXI8-P3i_cncRVn-tA@.rogers.com...
> > >I am designing a web application in asp.net C#, and I created classes
(in
> > > .cs files) working with the .aspx pages. Now, for database part...
> > > wondering which way is better:
> > > > 1. put database connectivity in the Classes, each class has the
> load/save
> > > data method? Many of my classes are inherited from each other, and
since
> I
> > > am using SQL 2000 which is a relational database makes the job little
> bit
> > > more complicated.
> > > > 2. put database connectivity in .aspx pages, then get/put the data
> > > from/into
> > > the classes when needed? This sounds easier, but is it a bad design?
> > > > Any suggestions are welcome.. thanks
> > >
I use Rocky's CLSA framework in a large ASP.Net.
It works great. The book is one of the best "reads" out there.
There is a whole Users forum available for discussing how to implement CSLA.
http://groups.msn.com/CSLANET/messages.msnw

Petar Kozul has added some *amazing* extensions to the framework with his
ActiveObjects.
http://csla.kozul.info/
--
Joe Fallon

"NOSPAM" <nospam@.xsagfgsagsafg.com> wrote in message
news:6d6dnSCkfaiQ6cncRVn-pg@.rogers.com...
> Is this the book I should read?
> http://www.amazon.com/exec/obidos/t...738524?v=glance
> I am going to buy if this is the one... Thanks a lot.
>
>
> "Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@.comcast.netNoSpamM> wrote in
> message news:eFgtCKmoEHA.2140@.TK2MSFTNGP11.phx.gbl...
>> I am not sure I like either. One methodology that works well is the
> creation
>> of a persistance layer that controls marshalling the business objects
>> from
>> the database to your app. You have methods in the class that force the
>> callback, but the object-relation mapping engine (persistence layer part)
> is
>> actually aware of how to get the data back. This is a better OO design,
> and
>> you can find examples on open source sites like SourceForge (including
>> code).
>>
>> Rockford Lhotka has his own design of a data "persistance" type of engine
>> that looks promising. It is in both his VB.NET and C# objects books. You
> can
>> download the code and adopt it for your site.
>>
>> Finally, ObjectSpaces will be out in a future Visual Studio. It allows
>> mapping via an XML Schema. Unfortunately, it has been dumped from Whidbey
>> timeframe, but you can still get the March preview and play around with
> the
>> idea. If you can get a similar method, you will be ready when
>> objectspaces
>> are finally available.
>>
>> --
>> Gregory A. Beamer
>> MVP; MCP: +I, SE, SD, DBA
>>
>> *************************************************
>> Think outside the box!
>> *************************************************
>> "NOSPAM" <nospam@.xsagfgsagsafg.com> wrote in message
>> news:OsCdnXI8-P3i_cncRVn-tA@.rogers.com...
>> >I am designing a web application in asp.net C#, and I created classes
>> >(in
>> > .cs files) working with the .aspx pages. Now, for database part...
>> > wondering which way is better:
>>> > 1. put database connectivity in the Classes, each class has the
> load/save
>> > data method? Many of my classes are inherited from each other, and
>> > since
> I
>> > am using SQL 2000 which is a relational database makes the job little
> bit
>> > more complicated.
>>> > 2. put database connectivity in .aspx pages, then get/put the data
>> > from/into
>> > the classes when needed? This sounds easier, but is it a bad design?
>>> > Any suggestions are welcome.. thanks
>>>>>
>>

Object oriented

i am a computer science student and i want to research about object oriented. can anyone introduce refrences except MSDN?

Try the links below for Microsoft patterns and practice and other free resources. Hope this helps.

http://msdn.microsoft.com/practices/
http://forums.asp.net/thread/932927.aspx

Object Oriented

Hi
I Have 2 questions:
1) what is the difference betweenObject oriented design andObject oriented programming?
2) what is "Client/Server programming-3-tier architecture" ?(the red sentence)
Thank youHi, it is lengthy to give you the full definition of 3-tier architecture and distinct difference betwween the OOD and OOP. You can get the answer fromhttp://en.wikipedia.org/ or Google by typing "define:keyword" here.

Hope this helps...
Answer to 2
- http://www.corba.ch/e/3tier.html

thank you ...It was very helpful

Object Orientation Articles?

Can anyone suggest me some good articles on the object orientated programming on the internet? any links would do.
Thanks
Hi,
here you can find an introduction toOOP in VB.NET.
Grz, Kris.

object orientated dropdownlist

I'm trying to create a simple way to bind a dropdown, suppling a table name a field for a value and a field for the name i want bound. I have setup properties elsewhere in the class

1Public Class DataBinderClass2Protected WithEvents ddlAs System.Web.UI.WebControls.DropDownList3Private _tableAs String4 Private _fieldNameAs String5 Private _fieldValueAs String67 Public Sub DropDownBinder()8Dim objConnectionAs System.Data.OleDb.OleDbConnection9 objConnection =New OleDbConnection(ConfigurationManager.ConnectionStrings("DocumentConn").ConnectionString)10 objConnection.Open()11'So Now the Application has an open connection to the specific db12Dim strSQLAs String ="SELECT " & fieldValue &", " & fieldName() &" FROM " & table() &""13Dim objCmdAs New OleDbCommand(strSQL, objConnection)14'Create/Populate the DataReader15Dim objDRAs OleDbDataReader16 objDR = objCmd.ExecuteReader()17 ddl.DataTextField ="fld_username"18 ddl.DataValueField ="fld_id"19 ddl.DataSource = objDR20 ddl.DataBind()21 objDR.Close()22 objConnection.Close()23End Sub2425 Property table()As String' sets the table we are goin to get data from26Get27 Return _table28End Get29 Set(ByVal ValueAs String)30 _table = Value31End Set32 End Property3334 Property fieldName()As String' sets the field to retrieve from table35Get36 Return _fieldName37End Get38 Set(ByVal ValueAs String)39 _fieldName = Value40End Set41 End Property4243 Property fieldValue()As String' sets the field which will hold the value44Get45 Return _fieldValue46End Get47 Set(ByVal ValueAs String)48 _fieldValue = Value49End Set50 End Property51 End Class
Dim dbindAs New DataBinderClass dbind.table ="tbl_users" dbind.fieldName ="fld_username" dbind.fieldValue ="fld_id" dbind.DropDownBinder()

I have a dropdown declared like this

<form runat="server">
<asp:DropDownList ID="ddl" runat="server">
</asp:DropDownList></form>

However I get an object not initialised error at line 17 even though I have a

Protected WithEvents ddlAs System.Web.UI.WebControls.DropDownList at the top of my class
Anyone any ideas how to hook up the codebehind with my control? 

The second line of your code should be

Protected WithEvents ddlAs New System.Web.UI.WebControls.DropDownList
Thanks 


Pass the DDL reference into the sub

Public Sub DropDownBinder(ByRef yourDDL as DropDownList)

I'd also suggest passing in the object collection. Then you can reuse this easily. I've done similar and it's been a great timesaver.


Many thanks for the quick reply guys- super I'll give that a go. Curt the dropdownlist ID is a good idea, but as I was debugging the current error, I didn't want to confuse things too much!

It seems by your connection string call sytnax that you are using VS 2005. If so it is very much cleaner to use the object tags that accompany the dropdownlist when you drag it onto the page. With the FlyOut Tag you can quickly define a SQL statement to pull in your data and then choose the text and values shown in the dropdown.

But the old "alot of code way" :

1'Loads Interesction drop down box: LstTo23Sub GetXStreets(ByVal stcodeAs Long,ByRef oConnAs SqlConnection)45Dim sqlQueryAs String67Dim oreader2As SqlDataReader89Dim intersectionsAs ArrayList1011Dim sqlqueryIntClauseAs String1213Dim intersectionAs Long1415Dim sqlquerystClause1617Dim icAs Integer1819Dim cstreetAs String2021intersections =New ArrayList(100)2223sqlQuery ="SELECT Distinct Intersection# FROM Geo_St_Pairs WHERE (ArbStreetCode2 = " & stcode &") OR (ArbStreetCode1 = " & stcode &")"2425Dim ocmd2As New SqlCommand(sqlQuery, oConn)2627oreader2 = ocmd2.ExecuteReader()2829intersections.Clear()3031Do While oreader2.Read()3233intersections.Add(oreader2("Intersection#"))3435Loop36373839oreader2.Close()4041LstTo.Items.Clear()4243sqlQuery ="Select distinct StreetOrFeatureName from GEO_STREETS where arbStreetCode in ("4445sqlqueryIntClause ="Intersection# IN ("4647For Each intersectionIn intersections4849sqlqueryIntClause = sqlqueryIntClause & Str(intersection) &","5051Next5253sqlqueryIntClause = sqlqueryIntClause &"-1) "5455sqlQuery ="SELECT DISTINCT ArbStreetCode1 AS StreetCode FROM Geo_st_Pairs WHERE arbstreetcode1 <> " & Str(stcode)5657sqlQuery = sqlQuery &" AND " & sqlqueryIntClause5859sqlQuery = sqlQuery &" UNION SELECT DISTINCT ArbStreetCode2 AS streetcodex FROM Geo_st_pairs WHERE arbstreetcode2 <> " & Str(stcode)6061sqlQuery = sqlQuery &" AND " & sqlqueryIntClause6263' Label3.Text = sqlQuery6465ocmd2.CommandText = sqlQuery6667oreader2 = ocmd2.ExecuteReader()6869sqlquerystClause =" ArbStreetCode IN ("7071While oreader2.Read()7273sqlquerystClause = sqlquerystClause & oreader2("streetCode") &","7475End While7677sqlquerystClause = sqlquerystClause &"-1)"7879sqlQuery ="SELECT ArbStreetCode, StreetPrefixDirection, StreetOrFeatureName, StreetType " _8081&"FROM GEO_STREETS WHERE " & sqlquerystClause _8283&" ORDER BY StreetOrFeatureName"8485'oreader2 = ocmd2.ExecuteReader(CommandBehavior.CloseConnection)8687oreader2.Close()8889ocmd2.CommandText = sqlQuery9091oreader2 = ocmd2.ExecuteReader()9293ic = 09495Do While oreader2.Read()9697'Build up the street String!!!9899If Not IsDBNull(oreader2("StreetPrefixDirection"))Then100101cstreet = oreader2("StreetPrefixDirection") &" "102103Else104105cstreet =" "106107End If108109cstreet = cstreet & oreader2("StreetOrFeatureName")110111If Not IsDBNull(oreader2("StreetType"))Then112113cstreet = cstreet &" " & oreader2("StreetType")114115End If116117LstTo.Items.Add(cstreet)118119LstTo.Items(ic).Value = oreader2("arbStreetCode")120121ic = ic + 1122123Loop124125oreader2.Close()126127' Label3.Text = SqlQuery128129130131Dim stCode2As Long132133Dim stCode1As Long134135Try136137stCode1 = LstAlong.SelectedItem.Value138139stCode2 = LstTo.Items(0).Value'push the first item even though not selected140141Dim sb77As System.Text.StringBuilder =New System.Text.StringBuilder142143sb77.Append("<SCRIPT LANGUAGE=javascript>")144145sb77.Append("SelectBoth" & Chr(40) &"'supersegs'," & stCode1 & "," & stCode2 & Chr(41) & ";")146147sb77.Append("</SCRIPT>")148149'Inject the script onto the page--control where exactly the script enters the page150151'must be after the header--where javascript.js in included152153RegisterStartupScript("IntersectScript", sb77.ToString())154155Catch ex As Exception156157Response.Write("<script>alert(" & Chr(34) & "check spelling of street: use first letter and scroll!" & Chr(34) & ");</script>")158159160161End Try162163164165End Sub166

Lines 117-123 are the most imprtant--showing the loop and the dropdownlist adding the values via this loop based on the sql queries.

LstTo dropdown called like this in HTML code:
<asp:dropdownlist id="LstTo" style="Z-INDEX: 102; LEFT: 16px; POSITION: absolute; TOP: 144px" runat="server"Width="160px" Height="19px" AutoPostBack="True"></asp:dropdownlist><BR>

Rox


I'd also suggest passing in the object collection.

Can you explain what you mean by the "object collection"?


Sub mySub(byRef ddl as DropDownList, byRef myObjColl as Generic.ListOf(Object))

or if you want you could actually do the proper object but then you would need a sub for ever object collection type you have.

I take it a few steps further...here is what I use (note the sub is overridden to allow a selected value):

Public Overridable Sub FillDropDown(ByVal DropDownList As DropDownList, _
ByVal ObjectCollection As Object, _
ByVal ValueField As String, _
ByVal TextField As String, _
ByVal AddBlank As Boolean)

DropDownList.DataTextField = TextField
DropDownList.DataValueField = ValueField
DropDownList.DataSource = ObjectCollection
DropDownList.DataBind()
If (AddBlank) Then DropDownList.Items.Insert(0, "")
End Sub

Public Overridable Sub FillDropDown(ByVal DropDownList As DropDownList, _
ByVal ObjectCollection As Object, _
ByVal ValueField As String, _
ByVal TextField As String, _
ByVal AddBlank As Boolean, _
ByVal SelectedValue As String)

DropDownList.DataTextField = TextField
DropDownList.DataValueField = ValueField
DropDownList.DataSource = ObjectCollection
DropDownList.DataBind()
If (AddBlank) Then DropDownList.Items.Insert(0, "")
DropDownList.SelectedValue = SelectedValue
End Sub