I think only one person would use your application at the same time... Or one call for one session. What happens a user opens two different pages at the same time...
It has too many problem... My advice u take a look at duwamish sample....
--
Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET
That's O.K.
But, as I have mention earlier :
... on every aspx page I need to open & close the
connection, if I do as your advise.
So I have solved it as follows :
------------------------------------------
If I put on session_start (global.asax.vb) the code :
Session("conMain") = me.conMain
(me.conMain is oleDBConnection).
I can reference on every of my aspx pages on their page_load event as following :
OleDBCommand1.Connection = Session("conMain").
(oleDBCommand1 is oleDBCommand).
----------------------------------------------------------------------
... which is much easier to maintenance
One thing is that on global.asax.vb the event : InitializeComponent is called twice, but only when first running the application
(If I run the application again : InitializeComponent isn't called).
And I don't understand why.
Another thing is that I was advised (former to this forum) not using global.asax.vb for using Session("conMain") -
Another thing I don't understand why.
Is my solution has any problem using it ?
Thanks
Juan T. Llibre said:
strConnection = ConfigurationSettings.AppSettings("ConnectionString")
sqlConn = New SqlConnection(strConnection)
- Where shall I put it (not web.config ?)
Either inline in your aspx page, or in your codebehind if you're using that.
Here's an inline example :
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim DS As DataSet
Dim MyConnection As String
Dim MyCommand As SqlDataAdapter
MyConnection = ConfigurationSettings.AppSettings("connNorthwind")
MyCommand = New SqlDataAdapter("select * from orders where orderid = 10270", MyConnection)
DS = New DataSet
MyCommand.Fill(DS, "Orders")
Repeater.DataSource = DS
Repeater.DataBind()
End Sub
This assumes that your web.config entry looks like this :
<configuration>
<appSettings>
<add key="connNorthwind" value="server=(local);trusted_connection=true;database=northwind"/>
</appSettings>
Make sure you replace *your* SQL server's name in this string.
re:
2) I presume that global variables for db configuration,
I best shall put it on web.config.
Yes.
Shall I put any of global variables on web.config (same method ,
<add key = "mynewkey" value = "mynewvalue" />
Exactly.
Now, for a news update :
All this changes in ASP.NET 2.0. News at 2.
Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================