I'm executing one stored procedure from the '.net' code. Since there is a lot of data, it is taking too much time to execute. Is there any way to stop this execution from the c# code?
In other words, if we execute the query from database itself, there is a option to stop its execution but in the code is it possible?
(I believe that this applies to both normal ASP.NET web parts and SharePoint hosted web parts)
The web part has an 'export' button that renders the output as csv and sets the appropriate headers so its opened in Excel.
Hooking in the buttons click event, clearing the response, adding the appropriate headers and content types is trivial - example
However I've noticed that if this code added to a web part and a debugger attached then if there are multiple instances of this (or any other) web part on the page then neither HTTPApplication.CompleteRequest or Response.End stop the processing/page lifecycle and all the events for all the page controls still fire.
This is wasteful in this example as the other web parts don't need to run - nothing they do will get to the response.
How to stop the execution and redirect to the login page. I tried FormsAuthentication.Signout but seens it doesn't stop the execution and let the code continue.
Select a from tbl_abc where id in ( select id from tbl_xyz where mainid = 12)
When I am executing this query, it is taking 1-2 seconds to execute, but when I am using the same query in stored procedure, the below query is taking more than 5 minute:
If(Select a from tbl_abc where id in ( select id from tbl_xyz where mainid = 12)) BEGIN -- CREATE TEMPORARY TABLE [Say: #temp1] #temp1 => Select a from tbl_abc where id in ( select id from tbl_xyz where mainid = 12) inserting the same value in the temp table drop #temp1 END
what could be the reason of this? and how can I resolve this? I am running the SP from asp.net
I need to find out the query execution time from the front end .Where should I insert the code for that.
I am using the bleow query:
OracleConnection con = new OracleConnection(ConnStr); con.Open(); OracleCommand cmd = new OracleCommand("Stored_Proc",con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(); .................... ................ OracleDataAdapter oda = new OracleDataAdapter (cmd);
when i am executing a simple query it is takeing 47 sec .... that is only for one table.. other then that remaing table perfromance is good... Help me out... and is there chance to get good perfomance through .net coding..
Can any one please provide link for flow of query exection in sql
For eg. FROM, [JOIN CONDITION, JOIN TABLE ...], WHERE, GROUP BY, HAVING, SELECT, DISTINCT, ORDER BY, TOP
Suppose when we write query, how that query will get execute behind. I would like to know about that. Can you please provide ariticles or link related to this
i am using the transaction-per-request (session-in-view) pattern for an asp.net web application. I have a couple of points in the application where i want to Save an NHibernate managed entity and then do a couple of more inserts and updates using common sql. These inserts/updates depend on the ID that the NH saved entity will take.
The problem is that the generated id does not exist in the transactions' scope. If i force a flush/commit the id is persisted but if the inserts/updates fail i have to rollback but the flushed/committed entity will not. Currently I'm doing a manual insert for these cases but that is something i want to change. So, is there a way to execute the SQL statement (inside the already open transaction) after the Save() but without forcing a flush/commit?
EDIT: I'm adding a semi-pseudocode example, i got 4 wrong answers so i think people don't understand (how NHibernate works) At the Begin request i issue a
nhsession.BeginTransaction()
then at some point i do
FooClass fc = new FooClass("value"); nhsession.Save(fc); ITransaction trans = nhsession.Transaction; SqlCommand sc = new SqlCommand("some insert/update query that depends on fc's id", (SqlConnection)nhsession.Connection); sc.Parameters.Add("id", fc.Id); //NHibernate generates the id, note i'm using assigned/hi-lo so no round trip to the db takes place transaction.Enlist(sc); try { sc.ExecuteNonQuery(); } catch (SqlException ex){ transaction.RollBack(); nhsession.Close(); }
and at the end of the Request i issue a CommitTransaction() and nhsession.Close()
Now this will do absolutely nothing: the FooClass (fc) has not been flushed/commited to the database. The Save() operation that NH has done is up to that point in-memory. That means no sql command has been issued by nhibernate and that means that the SqlCommand (sc) that i fire afterwards will fail miserably as the id does not exist.
If i do a flush/commit between Save() and the SqlCommand the FooClass(fc) _cannot_be_rolled_back_ and that is a bad bad thing.Currently, for this to work i make vanila sql insert using an SqlCommand, and i want to change that. (Why? because i don't want to make vanilla inserts they are susceptible to errors due to schema/model changes, and i got the OR/M for that)
How? i want to notify NHibernate somehow to execute the SqlCommand to corresponds to the Save() insert (hell, it can do all the SqlCommands it has gathered) but without it commiting or flushing!.
Currently i'm also searching for the prepared sql statement that nhibernate produces when flushing/commiting a saved object. Maybe i can just take that string and run it in my SqlCommand that is enlisted in the Transaction.
I'm building an ASP.NET MVC site that uses LINQ to SQL. In my search method that has some required and some optional parameters, I want to build a LINQ query while testing for the existence of those optional parameters.
Here's what I'm currently thinking: using(var db = new DBDataContext()) { IQueryable<Listing> query = null; //Handle required parameter query = db.Listings.Where(l => l.Lat >= form.bounds.extent1.latitude && l.Lat <= form.bounds.extent2.latitude); //Handle optional parameter if (numStars != null) query = query.Where(l => l.Stars == (int)numStars); //Other parameters... //Execute query (does this happen here?) var result = query.ToList(); //Process query...
Will this implementation "bundle" the where clauses and then execute the bundled query? If not, how should I implement this feature?
I have a class that being used to connect with the DB. Now I want to count how many times each web request executes the queries, but I've no idea where to store the counted value. I mean, Session wont, ViewState wont work as site also have webservices. What else I can use?
My task is to create an ASP.NET application with a piece of code which will automatically run every half an hour. This code must append a record to the file every half an hour. It should not depend on users requests(whether they happen or not).
1) I'm writing my code in Application.Start method of Global.asax file. Am I right?
2) Do I have anything to do with the hosting (IIS) settings (e.g. change permissions to write the file, etc)?
I have already tried just putting the code to write to file into a loop in Application.Start method and then just copied the project directory to the server. However, it didn't work.
I have a Gridview which is populated from an ObjectDataSource. Data Source has a control parameter hooked up to the SelectedDataKey value of the GridView. My Gridview has rows which may not have a DataKey. I am receiving an error when a GridView row without a DataKey is selected.
I am trying to use a variable from the code-behind page in a sqlDataSource WHERE statement. I am using Membership.GetUser().ProviderUserKey to obtain the UserId of the logged in user and I would like to only show record that have this UserId as a foreign key. How can I write the SQL for this?
Here is what I have so far:
SQL Query:
SelectCommand="SELECT [UserID], [CarID], [Make], [Model], [Year] FROM [Vehicle]"
I'm going to check the database schema at Application_Start event handle in the Global.asax file. If something wrong, I hope to stop the application instead of just catch an exception.
I have a repeater and a user control on my page, when any of the items in the repeater are selected this refreshes the user control accordingly. However I found that if I selected another item before the page/user control had finished to load it produced an error, when left to let the page/control fully load and reselect no error.Clearly this is interrupting the code before its finished, can I stop this from happening by doing some sort of check to see if the user control has finished loading?
my ddl1 and ddl2 in update panel so i want to insert item in ddl using following condition. It is working fine but when you choose ddl2 more than one then it insert item every time meand duplicate value and populate ddl1 every time.
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) { if (DropDownList2.SelectedValue=="1" ) { DropDownList1.Items.Insert(0, new ListItem("first", "1")); DropDownList1.Items.Insert(1, new ListItem("Second", "2")); DropDownList1.Items.Insert(2, new ListItem("Third", "3")); } else if (DropDownList2.SelectedValue == "2" ) { DropDownList1.Items.Insert(0, new ListItem("first", "1")); DropDownList1.Items.Insert(1, new ListItem("Second", "2")); } }
I set the line in code for debug and while running it does not stop there. So I use System.Diagnostics.Debugger.Break(). Sometimes it stops and sometimes the debugger shows a blank screen. All use the same inputs.