473,396 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ASP.NET architecture : am I missing something

Hi folks,

I am facing a little problem with my website that gives me an headache : It
can not have 2 users at the same time (quite annoying, as you see:))
I think I miss something in the ASP.NET architecture, but I can not see why
The problem stands in my connection to the database.

I have a unit that owns a SQLConnection object.
When a page is requested I call a class function that creates the SQL
object.

The fact is that this object seems to be shared amongst the users connected
to the site, when requesting a page at the same time.
That results in some odd errors telling connexion already opened and errors
like this. The problem disapears if only one visitor is connected to the
site.

Can someone help me ?
Thanks,

Julien
Nov 19 '05 #1
10 925
If you post the relevant code,
it will be easier to diagnose your problem.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Julien" <no****@toto.com> wrote in message news:43**********************@news.free.fr...
Hi folks,

I am facing a little problem with my website that gives me an headache : It can not have
2 users at the same time (quite annoying, as you see:))
I think I miss something in the ASP.NET architecture, but I can not see why
The problem stands in my connection to the database.

I have a unit that owns a SQLConnection object.
When a page is requested I call a class function that creates the SQL object.

The fact is that this object seems to be shared amongst the users connected to the site,
when requesting a page at the same time.
That results in some odd errors telling connexion already opened and errors like this.
The problem disapears if only one visitor is connected to the site.

Can someone help me ?
Thanks,

Julien

Nov 19 '05 #2
Have also implemented the "Close connection" functionality. Is this
connection object shared

-------
Regards ,
C#, VB.NET , SQL SERVER , UML , DESIGN Patterns Interview question book
http://www.geocities.com/dotnetinterviews/
My Interview Blog
http://spaces.msn.com/members/dotnetinterviews/

Nov 19 '05 #3
ok, but this is delphi code ... even if it is quite easy to understand
we use a persistance layer

-----------------------------
unit myUnit;

interface

type
TBDEObject = class(TDMObject)
procedure doSomething;
(...)

implementation

var sqlconn : SQLConnection;

function connect : boolean;
// this function initialize the sqlconn object

procedure TBDEObject.doSomething;
// in this procedure, the object sqlconn is used to work with the
database ...
// but this object seems to be shared amongst users

-------------------------------

In the initialization part of another unit, I call myUnit.connect
In the finalization part, I call myUnit.disconnect

I hope it helps ...

Julien

"Juan T. Llibre" <no***********@nowhere.com> a écrit dans le message de
news: ur**************@TK2MSFTNGP09.phx.gbl...
If you post the relevant code,
it will be easier to diagnose your problem.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Julien" <no****@toto.com> wrote in message
news:43**********************@news.free.fr...
Hi folks,

I am facing a little problem with my website that gives me an headache :
It can not have 2 users at the same time (quite annoying, as you see:))
I think I miss something in the ASP.NET architecture, but I can not see
why
The problem stands in my connection to the database.

I have a unit that owns a SQLConnection object.
When a page is requested I call a class function that creates the SQL
object.

The fact is that this object seems to be shared amongst the users
connected to the site, when requesting a page at the same time.
That results in some odd errors telling connexion already opened and
errors like this. The problem disapears if only one visitor is connected
to the site.

Can someone help me ?
Thanks,

Julien


Nov 19 '05 #4
I'm amused that Juan happened to get the only Delphi.Net question on
here....but I'm inclained to offer any help I can...

First, I don't know anything about Delphi ... but when I first read your
post, I figured you might be making improper use of static/shared members.
So I looked that concept up for Delphi and it turns out it doesn't have
anything exactly like that. A useful newsgroup post did mention that "the
workaround is to use the unit instead - a global var (initialized) or a
typed constant, in the Implementation section," which seems to be exactly
what you have.

In other words, it seems that you've made SqlConn a variable shared by all
instances. Of course, how you declare a private member field vs a static
field in Delphi is beyond me.

I would suggest that in ASP.Net, it's typical for each unit of functionality
to create and open an SqlConnection and close it ASAP where you have:

SqlConnection
Initialize()
DoSomething()
Cleanup()

I'd suggest you simply do:
DoSomething()

which internally has an Sqlconnection which is initialized and cleaned up.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Julien" <no****@toto.com> wrote in message
news:43**********************@news.free.fr...
ok, but this is delphi code ... even if it is quite easy to understand
we use a persistance layer

-----------------------------
unit myUnit;

interface

type
TBDEObject = class(TDMObject)
procedure doSomething;
(...)

implementation

var sqlconn : SQLConnection;

function connect : boolean;
// this function initialize the sqlconn object

procedure TBDEObject.doSomething;
// in this procedure, the object sqlconn is used to work with the
database ...
// but this object seems to be shared amongst users

-------------------------------

In the initialization part of another unit, I call myUnit.connect
In the finalization part, I call myUnit.disconnect

I hope it helps ...

Julien

"Juan T. Llibre" <no***********@nowhere.com> a écrit dans le message de
news: ur**************@TK2MSFTNGP09.phx.gbl...
If you post the relevant code,
it will be easier to diagnose your problem.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Julien" <no****@toto.com> wrote in message
news:43**********************@news.free.fr...
Hi folks,

I am facing a little problem with my website that gives me an headache :
It can not have 2 users at the same time (quite annoying, as you see:))
I think I miss something in the ASP.NET architecture, but I can not see
why
The problem stands in my connection to the database.

I have a unit that owns a SQLConnection object.
When a page is requested I call a class function that creates the SQL
object.

The fact is that this object seems to be shared amongst the users
connected to the site, when requesting a page at the same time.
That results in some odd errors telling connexion already opened and
errors like this. The problem disapears if only one visitor is connected
to the site.

Can someone help me ?
Thanks,

Julien



Nov 19 '05 #5
re:
I'm amused that Juan happened to get the only Delphi.Net question
Well, there just wasn't enough info in the post.

I requested more info, but I'd never have
imagined that the question was about Delphi.net.

;-)

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message
news:OD**************@TK2MSFTNGP11.phx.gbl... I'm amused that Juan happened to get the only Delphi.Net question on here....but I'm
inclained to offer any help I can...

First, I don't know anything about Delphi ... but when I first read your post, I figured
you might be making improper use of static/shared members. So I looked that concept up
for Delphi and it turns out it doesn't have anything exactly like that. A useful
newsgroup post did mention that "the workaround is to use the unit instead - a global
var (initialized) or a typed constant, in the Implementation section," which seems to be
exactly what you have.

In other words, it seems that you've made SqlConn a variable shared by all instances.
Of course, how you declare a private member field vs a static field in Delphi is beyond
me.

I would suggest that in ASP.Net, it's typical for each unit of functionality to create
and open an SqlConnection and close it ASAP where you have:

SqlConnection
Initialize()
DoSomething()
Cleanup()

I'd suggest you simply do:
DoSomething()

which internally has an Sqlconnection which is initialized and cleaned up.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Julien" <no****@toto.com> wrote in message
news:43**********************@news.free.fr...
ok, but this is delphi code ... even if it is quite easy to understand
we use a persistance layer

-----------------------------
unit myUnit;

interface

type
TBDEObject = class(TDMObject)
procedure doSomething;
(...)

implementation

var sqlconn : SQLConnection;

function connect : boolean;
// this function initialize the sqlconn object

procedure TBDEObject.doSomething;
// in this procedure, the object sqlconn is used to work with the database ...
// but this object seems to be shared amongst users

-------------------------------

In the initialization part of another unit, I call myUnit.connect
In the finalization part, I call myUnit.disconnect

I hope it helps ...

Julien

"Juan T. Llibre" <no***********@nowhere.com> a écrit dans le message de news:
ur**************@TK2MSFTNGP09.phx.gbl...
If you post the relevant code,
it will be easier to diagnose your problem.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Julien" <no****@toto.com> wrote in message
news:43**********************@news.free.fr...
Hi folks,

I am facing a little problem with my website that gives me an headache : It can not
have 2 users at the same time (quite annoying, as you see:))
I think I miss something in the ASP.NET architecture, but I can not see why
The problem stands in my connection to the database.

I have a unit that owns a SQLConnection object.
When a page is requested I call a class function that creates the SQL object.

The fact is that this object seems to be shared amongst the users connected to the
site, when requesting a page at the same time.
That results in some odd errors telling connexion already opened and errors like
this. The problem disapears if only one visitor is connected to the site.

Can someone help me ?
Thanks,

Julien



Nov 19 '05 #6
Karl,

Thanks for your suggestion.
I now open and close the connection before each database manipulation, and
sqlconn is a private object of the class.
If I open the connection in create an close in destroy, I get occasionnaly
the error 'there is already an open DataReader associated with this
Connection '
If I open and close before each database manipulation, I get others problems
showing that there other objects that seem to be shared amongst user ... for
instance I can sometimes grab the basket (which is a class too) of the other
person connected to the site :(
If you have over suggestions, you are welcome :)

Julien
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> a
écrit dans le message de news: OD**************@TK2MSFTNGP11.phx.gbl...
I'm amused that Juan happened to get the only Delphi.Net question on
here....but I'm inclained to offer any help I can...

First, I don't know anything about Delphi ... but when I first read your
post, I figured you might be making improper use of static/shared members.
So I looked that concept up for Delphi and it turns out it doesn't have
anything exactly like that. A useful newsgroup post did mention that "the
workaround is to use the unit instead - a global var (initialized) or a
typed constant, in the Implementation section," which seems to be exactly
what you have.

In other words, it seems that you've made SqlConn a variable shared by all
instances. Of course, how you declare a private member field vs a static
field in Delphi is beyond me.

I would suggest that in ASP.Net, it's typical for each unit of
functionality to create and open an SqlConnection and close it ASAP
where you have:

SqlConnection
Initialize()
DoSomething()
Cleanup()

I'd suggest you simply do:
DoSomething()

which internally has an Sqlconnection which is initialized and cleaned up.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Julien" <no****@toto.com> wrote in message
news:43**********************@news.free.fr...
ok, but this is delphi code ... even if it is quite easy to understand
we use a persistance layer

-----------------------------
unit myUnit;

interface

type
TBDEObject = class(TDMObject)
procedure doSomething;
(...)

implementation

var sqlconn : SQLConnection;

function connect : boolean;
// this function initialize the sqlconn object

procedure TBDEObject.doSomething;
// in this procedure, the object sqlconn is used to work with the
database ...
// but this object seems to be shared amongst users

-------------------------------

In the initialization part of another unit, I call myUnit.connect
In the finalization part, I call myUnit.disconnect

I hope it helps ...

Julien

"Juan T. Llibre" <no***********@nowhere.com> a écrit dans le message de
news: ur**************@TK2MSFTNGP09.phx.gbl...
If you post the relevant code,
it will be easier to diagnose your problem.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Julien" <no****@toto.com> wrote in message
news:43**********************@news.free.fr...
Hi folks,

I am facing a little problem with my website that gives me an headache
: It can not have 2 users at the same time (quite annoying, as you
see:))
I think I miss something in the ASP.NET architecture, but I can not see
why
The problem stands in my connection to the database.

I have a unit that owns a SQLConnection object.
When a page is requested I call a class function that creates the SQL
object.

The fact is that this object seems to be shared amongst the users
connected to the site, when requesting a page at the same time.
That results in some odd errors telling connexion already opened and
errors like this. The problem disapears if only one visitor is
connected to the site.

Can someone help me ?
Thanks,

Julien



Nov 19 '05 #7
Make sure to Close() your DataReader :)

karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Julien" <no****@toto.com> wrote in message
news:43***********************@news.free.fr...
Karl,

Thanks for your suggestion.
I now open and close the connection before each database manipulation, and
sqlconn is a private object of the class.
If I open the connection in create an close in destroy, I get
occasionnaly the error 'there is already an open DataReader associated
with this Connection '
If I open and close before each database manipulation, I get others
problems showing that there other objects that seem to be shared amongst
user ... for instance I can sometimes grab the basket (which is a class
too) of the other person connected to the site :(
If you have over suggestions, you are welcome :)

Julien
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> a
écrit dans le message de news: OD**************@TK2MSFTNGP11.phx.gbl...
I'm amused that Juan happened to get the only Delphi.Net question on
here....but I'm inclained to offer any help I can...

First, I don't know anything about Delphi ... but when I first read your
post, I figured you might be making improper use of static/shared
members. So I looked that concept up for Delphi and it turns out it
doesn't have anything exactly like that. A useful newsgroup post did
mention that "the workaround is to use the unit instead - a global var
(initialized) or a typed constant, in the Implementation section," which
seems to be exactly what you have.

In other words, it seems that you've made SqlConn a variable shared by
all instances. Of course, how you declare a private member field vs a
static field in Delphi is beyond me.

I would suggest that in ASP.Net, it's typical for each unit of
functionality to create and open an SqlConnection and close it ASAP where
you have:

SqlConnection
Initialize()
DoSomething()
Cleanup()

I'd suggest you simply do:
DoSomething()

which internally has an Sqlconnection which is initialized and cleaned
up.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Julien" <no****@toto.com> wrote in message
news:43**********************@news.free.fr...
ok, but this is delphi code ... even if it is quite easy to understand
we use a persistance layer

-----------------------------
unit myUnit;

interface

type
TBDEObject = class(TDMObject)
procedure doSomething;
(...)

implementation

var sqlconn : SQLConnection;

function connect : boolean;
// this function initialize the sqlconn object

procedure TBDEObject.doSomething;
// in this procedure, the object sqlconn is used to work with the
database ...
// but this object seems to be shared amongst users

-------------------------------

In the initialization part of another unit, I call myUnit.connect
In the finalization part, I call myUnit.disconnect

I hope it helps ...

Julien

"Juan T. Llibre" <no***********@nowhere.com> a écrit dans le message de
news: ur**************@TK2MSFTNGP09.phx.gbl...
If you post the relevant code,
it will be easier to diagnose your problem.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Julien" <no****@toto.com> wrote in message
news:43**********************@news.free.fr...
> Hi folks,
>
> I am facing a little problem with my website that gives me an headache
> : It can not have 2 users at the same time (quite annoying, as you
> see:))
> I think I miss something in the ASP.NET architecture, but I can not
> see why
> The problem stands in my connection to the database.
>
> I have a unit that owns a SQLConnection object.
> When a page is requested I call a class function that creates the SQL
> object.
>
> The fact is that this object seems to be shared amongst the users
> connected to the site, when requesting a page at the same time.
> That results in some odd errors telling connexion already opened and
> errors like this. The problem disapears if only one visitor is
> connected to the site.
>
> Can someone help me ?
> Thanks,
>
> Julien
>



Nov 19 '05 #8
well, the point is I don't have actually any datareader, but it fails with
this error on
mySQLDataAdapter.Fill(myTable); !

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> a
écrit dans le message de news: %2***************@TK2MSFTNGP10.phx.gbl...
Make sure to Close() your DataReader :)

karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Julien" <no****@toto.com> wrote in message
news:43***********************@news.free.fr...
Karl,

Thanks for your suggestion.
I now open and close the connection before each database manipulation,
and sqlconn is a private object of the class.
If I open the connection in create an close in destroy, I get
occasionnaly the error 'there is already an open DataReader associated
with this Connection '
If I open and close before each database manipulation, I get others
problems showing that there other objects that seem to be shared amongst
user ... for instance I can sometimes grab the basket (which is a class
too) of the other person connected to the site :(
If you have over suggestions, you are welcome :)

Julien
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> a
écrit dans le message de news: OD**************@TK2MSFTNGP11.phx.gbl...
I'm amused that Juan happened to get the only Delphi.Net question on
here....but I'm inclained to offer any help I can...

First, I don't know anything about Delphi ... but when I first read your
post, I figured you might be making improper use of static/shared
members. So I looked that concept up for Delphi and it turns out it
doesn't have anything exactly like that. A useful newsgroup post did
mention that "the workaround is to use the unit instead - a global var
(initialized) or a typed constant, in the Implementation section," which
seems to be exactly what you have.

In other words, it seems that you've made SqlConn a variable shared by
all instances. Of course, how you declare a private member field vs a
static field in Delphi is beyond me.

I would suggest that in ASP.Net, it's typical for each unit of
functionality to create and open an SqlConnection and close it ASAP
where you have:

SqlConnection
Initialize()
DoSomething()
Cleanup()

I'd suggest you simply do:
DoSomething()

which internally has an Sqlconnection which is initialized and cleaned
up.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Julien" <no****@toto.com> wrote in message
news:43**********************@news.free.fr...
ok, but this is delphi code ... even if it is quite easy to understand
we use a persistance layer

-----------------------------
unit myUnit;

interface

type
TBDEObject = class(TDMObject)
procedure doSomething;
(...)

implementation

var sqlconn : SQLConnection;

function connect : boolean;
// this function initialize the sqlconn object

procedure TBDEObject.doSomething;
// in this procedure, the object sqlconn is used to work with the
database ...
// but this object seems to be shared amongst users

-------------------------------

In the initialization part of another unit, I call myUnit.connect
In the finalization part, I call myUnit.disconnect

I hope it helps ...

Julien

"Juan T. Llibre" <no***********@nowhere.com> a écrit dans le message de
news: ur**************@TK2MSFTNGP09.phx.gbl...
> If you post the relevant code,
> it will be easier to diagnose your problem.
>
>
>
> Juan T. Llibre, ASP.NET MVP
> ASP.NET FAQ : http://asp.net.do/faq/
> Foros de ASP.NET en Español : http://asp.net.do/foros/
> ======================================
> "Julien" <no****@toto.com> wrote in message
> news:43**********************@news.free.fr...
>> Hi folks,
>>
>> I am facing a little problem with my website that gives me an
>> headache : It can not have 2 users at the same time (quite annoying,
>> as you see:))
>> I think I miss something in the ASP.NET architecture, but I can not
>> see why
>> The problem stands in my connection to the database.
>>
>> I have a unit that owns a SQLConnection object.
>> When a page is requested I call a class function that creates the SQL
>> object.
>>
>> The fact is that this object seems to be shared amongst the users
>> connected to the site, when requesting a page at the same time.
>> That results in some odd errors telling connexion already opened and
>> errors like this. The problem disapears if only one visitor is
>> connected to the site.
>>
>> Can someone help me ?
>> Thanks,
>>
>> Julien
>>
>
>



Nov 19 '05 #9
Fill internally uses a DataReader. Is the connection itself being closed?
Is the DataAdapter being disposed when you are done with it? It really does
sound like cleanup not taking place.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Julien" <no****@toto.com> wrote in message
news:43***********************@news.free.fr...
well, the point is I don't have actually any datareader, but it fails with
this error on
mySQLDataAdapter.Fill(myTable); !

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> a
écrit dans le message de news: %2***************@TK2MSFTNGP10.phx.gbl...
Make sure to Close() your DataReader :)

karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Julien" <no****@toto.com> wrote in message
news:43***********************@news.free.fr...
Karl,

Thanks for your suggestion.
I now open and close the connection before each database manipulation,
and sqlconn is a private object of the class.
If I open the connection in create an close in destroy, I get
occasionnaly the error 'there is already an open DataReader associated
with this Connection '
If I open and close before each database manipulation, I get others
problems showing that there other objects that seem to be shared amongst
user ... for instance I can sometimes grab the basket (which is a class
too) of the other person connected to the site :(
If you have over suggestions, you are welcome :)

Julien
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
a écrit dans le message de news:
OD**************@TK2MSFTNGP11.phx.gbl...
I'm amused that Juan happened to get the only Delphi.Net question on
here....but I'm inclained to offer any help I can...

First, I don't know anything about Delphi ... but when I first read
your post, I figured you might be making improper use of static/shared
members. So I looked that concept up for Delphi and it turns out it
doesn't have anything exactly like that. A useful newsgroup post did
mention that "the workaround is to use the unit instead - a global var
(initialized) or a typed constant, in the Implementation section,"
which seems to be exactly what you have.

In other words, it seems that you've made SqlConn a variable shared by
all instances. Of course, how you declare a private member field vs a
static field in Delphi is beyond me.

I would suggest that in ASP.Net, it's typical for each unit of
functionality to create and open an SqlConnection and close it ASAP
where you have:

SqlConnection
Initialize()
DoSomething()
Cleanup()

I'd suggest you simply do:
DoSomething()

which internally has an Sqlconnection which is initialized and cleaned
up.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Julien" <no****@toto.com> wrote in message
news:43**********************@news.free.fr...
> ok, but this is delphi code ... even if it is quite easy to understand
> we use a persistance layer
>
> -----------------------------
> unit myUnit;
>
> interface
>
> type
> TBDEObject = class(TDMObject)
> procedure doSomething;
> (...)
>
> implementation
>
> var sqlconn : SQLConnection;
>
> function connect : boolean;
> // this function initialize the sqlconn object
>
> procedure TBDEObject.doSomething;
> // in this procedure, the object sqlconn is used to work with the
> database ...
> // but this object seems to be shared amongst users
>
> -------------------------------
>
> In the initialization part of another unit, I call myUnit.connect
> In the finalization part, I call myUnit.disconnect
>
> I hope it helps ...
>
> Julien
>
> "Juan T. Llibre" <no***********@nowhere.com> a écrit dans le message
> de news: ur**************@TK2MSFTNGP09.phx.gbl...
>> If you post the relevant code,
>> it will be easier to diagnose your problem.
>>
>>
>>
>> Juan T. Llibre, ASP.NET MVP
>> ASP.NET FAQ : http://asp.net.do/faq/
>> Foros de ASP.NET en Español : http://asp.net.do/foros/
>> ======================================
>> "Julien" <no****@toto.com> wrote in message
>> news:43**********************@news.free.fr...
>>> Hi folks,
>>>
>>> I am facing a little problem with my website that gives me an
>>> headache : It can not have 2 users at the same time (quite annoying,
>>> as you see:))
>>> I think I miss something in the ASP.NET architecture, but I can not
>>> see why
>>> The problem stands in my connection to the database.
>>>
>>> I have a unit that owns a SQLConnection object.
>>> When a page is requested I call a class function that creates the
>>> SQL object.
>>>
>>> The fact is that this object seems to be shared amongst the users
>>> connected to the site, when requesting a page at the same time.
>>> That results in some odd errors telling connexion already opened and
>>> errors like this. The problem disapears if only one visitor is
>>> connected to the site.
>>>
>>> Can someone help me ?
>>> Thanks,
>>>
>>> Julien
>>>
>>
>>
>
>



Nov 19 '05 #10
Hi,

I finally found the solution.
In Delphi, global variables defined in an unit are static, so they are
common to every client that connects to the application.
So I have listed all the variable that are client-dependant, then I built
an object with class properties to store these objects in the session
object.
Now it works like a charm :)
Thanks for your help,

Julien
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> a
écrit dans le message de news: eF**************@TK2MSFTNGP15.phx.gbl...
Fill internally uses a DataReader. Is the connection itself being closed?
Is the DataAdapter being disposed when you are done with it? It really
does sound like cleanup not taking place.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Julien" <no****@toto.com> wrote in message
news:43***********************@news.free.fr...
well, the point is I don't have actually any datareader, but it fails
with this error on
mySQLDataAdapter.Fill(myTable); !

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> a
écrit dans le message de news: %2***************@TK2MSFTNGP10.phx.gbl...
Make sure to Close() your DataReader :)

karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Julien" <no****@toto.com> wrote in message
news:43***********************@news.free.fr...
Karl,

Thanks for your suggestion.
I now open and close the connection before each database manipulation,
and sqlconn is a private object of the class.
If I open the connection in create an close in destroy, I get
occasionnaly the error 'there is already an open DataReader associated
with this Connection '
If I open and close before each database manipulation, I get others
problems showing that there other objects that seem to be shared
amongst user ... for instance I can sometimes grab the basket (which is
a class too) of the other person connected to the site :(
If you have over suggestions, you are welcome :)

Julien
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
a écrit dans le message de news:
OD**************@TK2MSFTNGP11.phx.gbl...
> I'm amused that Juan happened to get the only Delphi.Net question on
> here....but I'm inclained to offer any help I can...
>
> First, I don't know anything about Delphi ... but when I first read
> your post, I figured you might be making improper use of static/shared
> members. So I looked that concept up for Delphi and it turns out it
> doesn't have anything exactly like that. A useful newsgroup post did
> mention that "the workaround is to use the unit instead - a global var
> (initialized) or a typed constant, in the Implementation section,"
> which seems to be exactly what you have.
>
> In other words, it seems that you've made SqlConn a variable shared by
> all instances. Of course, how you declare a private member field vs
> a static field in Delphi is beyond me.
>
> I would suggest that in ASP.Net, it's typical for each unit of
> functionality to create and open an SqlConnection and close it ASAP
> where you have:
>
> SqlConnection
> Initialize()
> DoSomething()
> Cleanup()
>
> I'd suggest you simply do:
> DoSomething()
>
> which internally has an Sqlconnection which is initialized and cleaned
> up.
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
> "Julien" <no****@toto.com> wrote in message
> news:43**********************@news.free.fr...
>> ok, but this is delphi code ... even if it is quite easy to
>> understand
>> we use a persistance layer
>>
>> -----------------------------
>> unit myUnit;
>>
>> interface
>>
>> type
>> TBDEObject = class(TDMObject)
>> procedure doSomething;
>> (...)
>>
>> implementation
>>
>> var sqlconn : SQLConnection;
>>
>> function connect : boolean;
>> // this function initialize the sqlconn object
>>
>> procedure TBDEObject.doSomething;
>> // in this procedure, the object sqlconn is used to work with the
>> database ...
>> // but this object seems to be shared amongst users
>>
>> -------------------------------
>>
>> In the initialization part of another unit, I call myUnit.connect
>> In the finalization part, I call myUnit.disconnect
>>
>> I hope it helps ...
>>
>> Julien
>>
>> "Juan T. Llibre" <no***********@nowhere.com> a écrit dans le message
>> de news: ur**************@TK2MSFTNGP09.phx.gbl...
>>> If you post the relevant code,
>>> it will be easier to diagnose your problem.
>>>
>>>
>>>
>>> Juan T. Llibre, ASP.NET MVP
>>> ASP.NET FAQ : http://asp.net.do/faq/
>>> Foros de ASP.NET en Español : http://asp.net.do/foros/
>>> ======================================
>>> "Julien" <no****@toto.com> wrote in message
>>> news:43**********************@news.free.fr...
>>>> Hi folks,
>>>>
>>>> I am facing a little problem with my website that gives me an
>>>> headache : It can not have 2 users at the same time (quite
>>>> annoying, as you see:))
>>>> I think I miss something in the ASP.NET architecture, but I can not
>>>> see why
>>>> The problem stands in my connection to the database.
>>>>
>>>> I have a unit that owns a SQLConnection object.
>>>> When a page is requested I call a class function that creates the
>>>> SQL object.
>>>>
>>>> The fact is that this object seems to be shared amongst the users
>>>> connected to the site, when requesting a page at the same time.
>>>> That results in some odd errors telling connexion already opened
>>>> and errors like this. The problem disapears if only one visitor is
>>>> connected to the site.
>>>>
>>>> Can someone help me ?
>>>> Thanks,
>>>>
>>>> Julien
>>>>
>>>
>>>
>>
>>
>
>



Nov 19 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: David Noble | last post by:
We've been developing a web site using 3-tier architecture for 18 months now. There is a common layer that defines the classes - using XML schemas. The data layer acts as a wrapper to 3 databases...
3
by: Johnny Meredith | last post by:
Hi, I'm relaively new to programming languages in general, and brand new to VB.NET. I use/used VBA in MS Access previously to do what I needed. I want to learn VB.NET to stretch my boundaries a...
3
by: Johnny Meredith | last post by:
Hi, I'm relaively new to programming languages in general, and brand new to VB.NET. I use/used VBA in MS Access previously to do what I needed. I want to learn VB.NET to stretch my boundaries a...
2
by: WXS | last post by:
When I see things in .NET 2.0 like obsoletion of suspend/resume because of the public reason MS gives of they think people are using them inappropriately.. use mutex, monitor and other...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.