Yes; the usual reaction is to figure out how to "cancel the query".
Perhaps one should first look at "tuning" the query.
The "query" is being confused with the "what it is that is submitting the query" (existentially speaking). The "query" is the "database server engine"; not some thread that submitted the query.
Is the query returning a scalar or a "set"?
If a set, is it required to be viewed and paged? Reported on?
Is virtualization an option for "paged" results.
Can the execution plan be estimated and presented before kicking off the query?
What is the nature of query? Would a data reader suffice? Can intermediate results be used to confirm kicking of further queries instead of resorting to a single "large" (poorly optimized) query (e.g. when "drilling" down).
These are user created queries, so there is no tuning the query.
Yes, I guess you are correct. The query is being run by the database server engine, so I guess there is no canceling the query. All I can really do is force my program to stop waiting for the query results. I guess since the query is running in a transaction, I could try rolling back the transaction.
The query returns a set.
The query is created by the user through a query designer that we wrote in C#. It only allows the user to execute SELECT queries against tables or Views in the database. It returns a dataset with the results displayed in a datagrid. The results can then be exported to a CSV or XLSX file.
Hi Gerry. They do not have free unlimited access to everything. We use User Roles to control what they have access to. They cannot run Action Queries or DROP or CREATE queries. If the application needs to do that, then we use an Application Role with elevated permissions. We have covered our bases I think.
Also, just to be safe, we have an algorithm that validates their query and looks for those action query keywords such as DROP, DELETE, INSERT, CREATE, UPDATE, etc. It will not allow anyone to run queries with those keywords. We also have the user pick the tables that they want to run their query against from a combo box. The algorithm that loads the combo box only lists certain tables.
When I said "free access", I did not mean: DELETE; DROP; etc.
I meant that a person who works in "Accounts Receivable" (AR) typically only deals with "AR" data that is current for the month, and a few previous; and NOT to xx years of data for every department in the company.
That's why one has "performance problems": users (or anybody) running "dumb" queries.
And if you need to "cancel it", it cannot have been that important.
If it WAS important, one typically creates a "canned query"; with a few "optional parameters".
Anything else is chaos; and you get blamed for the performance issues.
In our environment, our SQL Server is on a non-Internet connected machine. And the data is Analysis data. More and more data is added on a regular basis. We have many millions of rows of data in several databases. Our data analysts run queries. Sometimes they create a query incorrectly (or inefficient) . We have had cases where a user will start a query before they go home for the day, and then when they come in the next morning, it is still running.
Some of our queries consist of many views joined together and some of them use scalar functions and table valued functions which get used repeatedly. This can of course slow the query down significantly. Anyway, previously the only way to cancel a query was to End Task on the program, now the user can just click the cancel button. It works very well.
With ERP systems, I configured the query screens based on the "questions" users wanted to ask; that always involved some combination of: Company; Department; Cost Centre; Client #; Invoice #; Work order $; Year; Month; Day; etc.
Some required fields; some optional; default values off the accounting cycle. Write once (all variations of the same but limited to "codes" in their HR profile).
Every new table / "entity" is automatically secured based on "need to know".
No "bad" queries in the "operational" world; for the "informational" needs (different ASAP), there is the data warehouse. Two worlds.
I want to make a tool for loging form of facebook.
In the past i was make facebook windows form application in xmpp client connection, that was working but now facebook setting change and i can not design a login form with xmpp.
I want to design a windows form application with user name and password text box for facebook, please help me.
How can i login to facebook server with windows form application
So I need your help to get a value from a string and put it on other field. I saw tons of exemples around, but I have several issues.
So I have a field named "Comments". I need to check if that field has some words on it. After find one of those words, I need to get the value after that word and pass it to another field named "Selo".
Issue 1: I filled the fields "Comments" but in VisualStudio - Watch, this field is allways null, so everything else is null. Issue 2: When I change the "Comments" data, the VS Watch recognizes changes and passes all the data in this field to the "Selos" field, which is not what I want. I just want data after stringToCheck...
Here's an exemple:
Comments: Everythings OK. Selo: Q457896; Q457897
Now, the code puts in "Selo" field: Everythings OK. Selo: Q457896; Q457897, however, it doesn't save this value in the database. What I really want is:
Field Selo - Q457896; Q457897
Please I need your help to get this working... What am I missing/doing wrong here?
So if I get you correctly you want to update the property Selo if the comments property has the word "Selo" or some other pre-defined variable in it or add the first value from the comments once it has been broken up.
First, a caveat. There is not enough code he to get a complete picture of what you're doing and how you're using this code.
You're using a property incorrectly. You're using it as essentially a readonly property and a method to try and parse an input. I'd probably break this into a REAL readonly property with only a getter and then a method to parse the input and set the property backing field. You're not using the value supplied by the property settor.
The backing field I would probably rename to _selos to make sure its differentiated from all other mentions of it in the code.
The method to parse the input would probably be easier with a regular expression instead of using the "magic values" and very nainve method you're using. What if the comment contains "sEro:"? It's going to fail. Use a case-insensitive check instead.
Also, when you split the Comment string you're using the first element in the resulting string array, which is always going to be to first word in the Comment, in your example it's "Everything".
Free form user input is not the best idea. If you can avoid it, do so. If not, treat it like it's out to destroy the world. Don't trust it to contain anything usable at all and if it does, don't trust it to be in a format you can easily parse.
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself.
Let me just explain what the error means: You have tried to use a variable, property, or a method return value but it contains null - which means that there is no instance of a class in the variable.
It's a bit like a pocket: you have a pocket in your shirt, which you use to hold a pen. If you reach into the pocket and find there isn't a pen there, you can't sign your name on a piece of paper - and you will get very funny looks if you try! The empty pocket is giving you a null value (no pen here!) so you can't do anything that you would normally do once you retrieved your pen. Why is it empty? That's the question - it may be that you forgot to pick up your pen when you left the house this morning, or possibly you left the pen in the pocket of yesterdays shirt when you took it off last night.
We can't tell, because we weren't there, and even more importantly, we can't even see your shirt, much less what is in the pocket!
Back to computers, and you have done the same thing, somehow - and we can't see all your code, much less run it and find out what contains null when it shouldn't.
But you can - and Visual Studio will help you here. Run your program in the debugger and when it fails, VS will show you the line it found the problem on. You can then start looking at the various parts of it to see what value is null and start looking back through your code to find out why. So put a breakpoint at the beginning of the method containing the error line, and run your program from the start again. This time, VS will stop before the error, and let you examine what is going on by stepping through the code looking at your values.
But we can't do that - we don't have your code, we don't know how to use it if we did have it, we don't have your data. So try it - and see how much information you can find out!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
I'm creating a C# app with an SQL Server database.
In one module, the user has the option to filter the results by clicking on one of the two radio buttons (one is already selected by default), and I don't want to have to keep on re-accessing the database each time the user switches between the filters as it might consume time when the app has to load the data.
I'm using DataAdapter, DataTable, and DataGridView
Is there a way for me to somehow store the data from the database in a cache and then access them and show results that match the filter? How?