|
Can anybody help in developing the asp.net application with multiple users using sqlconnection.
We have written connectionstring in web.config file but still application is working for multiple sql connection.
|
|
|
|
|
So, what do you want to achieve? That all users are using a single sql connection (then you have to use a static connection - singleton pattern), or every user has its own connection (then use an instance for each user and store it within the session).
Regards
Sebastian
|
|
|
|
|
So can u provide singleton pattern example.
|
|
|
|
|
public static class GlobalConnection
{
public static readonly SqlConnection Value;
static GlobalConnection()
{
Value = new SqlConnection("...");
Value.Open();
}
}
Everywhere you need the connection you call:
GlobalConnection.Value
But this approach will:
1 - Use a single connection for all clients and threads.
2 - Will not reconnect if the connection is lost.
But maybe this works for your needs or as a sample on how to do the job.
Another approach will be:
public static class GlobalConnection
{
private static object _lock = new object();
private static SqlConnection _value;
public static SqlConnection Value
{
get
{
lock (_lock)
{
if (_value == null)
_value = new SqlConnection("...");
switch(_value.State)
{
case ConnectionState.Closed:
case ConnectionState.Broken:
_value.Open();
break;
}
}
}
}
}
This one will reopen the connection if it is closed.
|
|
|
|
|
Hi
i have a page where iam binding a gridview to a datatable that is selcting from a sql database table that has one clustered and 3 nonclustered indexes. On rowdatabound iam doing some calculations/counting not very complex and loading them in several viewstates. The execution time of stored procedure that selects the data takes less than a second to ececute. as a result i assume that it is not a database issue.
The issue is that when i dont allow paging on the gridview, the page takes around 4 minutes to load(the grid return 400 rows only). When i allow paging = 50 then it takes 3-4 seconds.
I have debbuged and didnt reach a result everything is working fine page load, master page load....
Is there a way i can tell the cause root of the problem. Thanks
modified on Thursday, April 30, 2009 4:48 AM
|
|
|
|
|
samerh wrote: The issue is that when i dont allow paging on the gridview, the page takes around 4 minutes to load(the grid return 400 rows only). When i allow paging = 50 then it takes 3-4 seconds.
Why are you showing 400 Records in Grid. You can minimize the records to improve the performance. Show maximum 50 Records or may be less than that in grid. If you think it will increase the total page size, set the filter criteria to minimize the records.
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
Abhijit Jana wrote: Why are you showing 400 Records in Grid. You can minimize the records to improve the performance.
400 records is not a huge amount. Isn't it?
|
|
|
|
|
Hmmmm this is the problem the user wants to view all records. i cant convince him at all
|
|
|
|
|
Hi,
I have to share following poitns regarding your question:
(i) Showing all records (400+) in a gridview without using pagination may cause a huge performance lack. You know it as you observed that page loading time differences.
(ii) Run SQL Profiler while executing your application. Check whether there is any scope for the sql query optimization or not.
(iii) Use Fiddler Web Debugger or YSlow like tools which will tell you the detailed analysis about the page execution processes.
Hope it helps.
Either you love IT or leave IT...
|
|
|
|
|
i- yes indeed
ii- i already did it, iam sure it is ot a sql issue execution time of query take 0.3 seconds
iii- i will give them a try
thanks
|
|
|
|
|
samerh wrote: On rowdatabound iam doing some calculations/counting not very complex and loading them in several viewstates
Can we see this code? Best way is to use StopWatch[^] class and measure the time each method is taking. This will help you to find where the bottleneck is (I guess Christian got an article on doing this).
|
|
|
|
|
i can understand what ur thinking of, but calculations are nothing iam just counting number of rows if a value equal someting (4 counts with 4 viewstates).
|
|
|
|
|
Hi!
I had a similar problem som month ago.
I came to the conclusion that the accual time consumer is the webbrowser.
It takes quite some time for the browser to render a such big table.
Andreas Johansson
IT Professional at Office IT Partner i Norrbotten Sweden
What we don't know. We learn. What you don't know. We teach
|
|
|
|
|
You can try for incremental page load.
Don't load all 400 rows at once. Instead, load first few rows first, then append the rows to the GridView using ajax.
Hope it will help.
|
|
|
|
|
In my opinion, the difference of time is due to the ViewState usage. Have you tried to put all the 400 rows in the grid without putting any data in the ViewState? Or even try to disable the EnableViewState from the Grid control.
Even if you need the ViewState, you at least can check if the problem is caused by the viewstate or not.
As I see:
You load all records into the grid, with generates real data (the HTML of the grid) and put data into the ViewState.
Then you put the DataTable you used to do the query also in the ViewState, and at the end you have a huge ViewState that causes all the problem.
|
|
|
|
|
Please could someone help me
I want to create a popup window.
Now i've created the window in a ascx file.
Now what i would like to do is make the control work like other asp controls
for e.g.
<tst:mycontrol runat = "server" ID= "test1" >
<content>
......
</content>
</tst:test>
what i would like to to is add whatever into the content space.
I dont realy know alot about creating my own controls but is this posible??
|
|
|
|
|
Yes, u can create ur own user control and use that in ur aspx page like other asp controls.
But u have to register ur control (either in each page or in web config).
u can use <%@ Register TagName="tagname" TagPrefix="tagprefix" Src="~/usercntrl.ascx" %>
in top of the aspx page and use ur user control
<tagprefix:tagname id="test1" runat="server">
Hope it helps u
|
|
|
|
|
Thanks for the reply
I know how to create and use the ascx controls but i want to add extra functionality to it
let me try and explain it in another way.
I want to make like for e.g. the asp panel it would be used like this
<asp:Panel ID = "panel1" runat = "server">
<table>
<tr>
<td>
<asp:Button id = "b1" runat = "server" text ="Click Me" />
</td>
</tr>
</table>
</asp:Panel>
now what i want to do is like the same way you use the panel to place something inside , i want to use my custom control
just again , its a popup window and i would like to use some sort of place holder where i can place stuff in
for e.g. i would want to use the window for error messges or to put in a few textboxes and labels.
like this
<tst:mycontrol runat ="server" >
<content>
<table>
<tr>
<td>
<asp:Button id = "b1" runat = "server" text ="Click Me" />
</td>
</tr>
</table>
</content>
</tst:mycontrol>
|
|
|
|
|
If it's a popup, it's a seperate window, not a control.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
sory about the way my posts are looking , they dont display right on my side,
anyways ,
i know its a different window ,
i want to use it with the ajaxmodalpopup extender ,
the way i want to create the control must be like a template of some sorts ,
I'm putting in a label header which can be changed with the control's properties
and then in the middle i want a place holder where i can place buttons or tables and stuff,
like this
<tst:mycontrol runat ="server" id = "tst1" HeaderText = "Error">
<content>
....... (maybe table with message in and a button to click ok)
</content>
</tst:mycontrol>$
|
|
|
|
|
Hi all,
I have a html editor,i bind the value from the DB to the textarea.then i update the binded text and assigned it another variable.But the varible holds the value which is initially binded.I cant save the Updated text from Html editor.
Can any one help me..
|
|
|
|
|
Can you pastered this code? DB it's bind ,and update it.
|
|
|
|
|
Can you post the code? From your question, I doubt whether you are using web application or not. You may be binding the text area control in the page load. Now this binding code may have been written outside if(!IsPostBack) region. So, whenever you are clicking on the update button, postback is happening and control goes to the page load and it si rebinding the old value to the textarea. So, if you are doing so then put the data binding code inside !IsPostback region.
Either you love IT or leave IT...
|
|
|
|
|
Hi experts,
how to create dymamic textboxes using javascript in asp.net without postback
beula.
CMOTS Infotech,
Capital Market.
|
|
|
|
|
Use Google[^]
"Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)
|
|
|
|