B
Bijoy Naick
Hello,
I am writing an application which uses SQL Server as the database.. Some
questions...
1. Just want to confirm that using SQLConnection is the best way connect the
db..
2. The application will contain multiple pages.. Each page will have to
connect to the db and perform some actions against it. So, on each page I
will have to declare variables for the connection, command, reader, sql
statement and connection string. I will also have to create the connection,
open it, create a new command object, run the query, then close the reader
and connections.
Does it make sense to build a "MyDBConnection" class which encapsulates all
of this?? So that when I create an instance of this class, it opens the
connection.. I can have a public function called RunQuery which accepts a
SQL text string as input and returns a reader. Then all I have to do is
create an object of this class on every page and invoke the RunQuery method?
Is this recommeded, advisable, doable? Any issues?
Thx.
Bijoy
I am writing an application which uses SQL Server as the database.. Some
questions...
1. Just want to confirm that using SQLConnection is the best way connect the
db..
2. The application will contain multiple pages.. Each page will have to
connect to the db and perform some actions against it. So, on each page I
will have to declare variables for the connection, command, reader, sql
statement and connection string. I will also have to create the connection,
open it, create a new command object, run the query, then close the reader
and connections.
Does it make sense to build a "MyDBConnection" class which encapsulates all
of this?? So that when I create an instance of this class, it opens the
connection.. I can have a public function called RunQuery which accepts a
SQL text string as input and returns a reader. Then all I have to do is
create an object of this class on every page and invoke the RunQuery method?
Is this recommeded, advisable, doable? Any issues?
Thx.
Bijoy