|
|
And you are telling me this for a reason!!!
Also while the answer is technically correct it is the wrong solution, the archives need to be changed but the production database.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Notice the site-driving spam link at the bottom of the message.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
i created an event on one of my db to kill process using root as the definer.
DELIMITER $$
CREATE DEFINER='root'@'localhost' EVENT `db`.`kill_processes`
ON SCHEDULE EVERY 5 SECOND
ENABLE
DO
BEGIN
DECLARE process_to_kill VARCHAR(25);
DECLARE done BOOLEAN DEFAULT FALSE;
DECLARE find_process CURSOR FOR
SELECT CONCAT('KILL ', `ID`, ';') FROM `information_schema`.`PROCESSLIST`
WHERE `information_schema`.`PROCESSLIST`.`USER` = 'some_user' AND
`information_schema`.`PROCESSLIST`.`COMMAND` = 'Sleep' AND
`information_schema`.`PROCESSLIST`.`TIME` > 90;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN find_process;
loop_process : LOOP
FETCH find_process INTO process_to_kill;
IF done THEN
CLOSE find_process;
LEAVE loop_process;
END IF;
SET @f_p = find_process;
PREPARE stmt FROM @f_p;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END LOOP loop_process;
END$$
DELIMITER ;
but unfortunately it is not working, the event is executing every 5 seconds but it doesnt kill any process that is runnig more than 90 seconds.
any help will be appreciated.
thanks
|
|
|
|
|
anyone please
|
|
|
|
|
I am do dumb to to write this and didn't figure it out quickly
SET @f_p = find_process;
BTW it is working now
|
|
|
|
|
how are you all.
i am new to asp.net and c#. i need help.
well my question is, i have a textbox in which a user have to enter a float value in the webform.
and i want to manipulate that value in a calculation.
so have created a class for the calculation which is Sales class. in that class i have declared Price as a float value,the value which should be obtained from the textbox.ie public float Price {get;set;}
Now my problem is with binding/linking the Price variable with the textbox in the button_click method.
initially i had done it this way:
in my .aspx.cs file i have created an object of the class in this case :
Sales s = new Sales ();
protected void button_Click (object sender EventArgs e)
{
s.Price =Convert.ToInt32(Textbox1.Text);
s.Save();
}
i want the Price value to be saved in my database after a user clicks the SAVE button from the webform.
Now the problem is when i run the application there is an error (
An exception of type 'System.NullReferenceException' occurred in Version1.dll but was not handled in user code )
on the line :
s.Price = Convert.ToInt32(Textbox1.Text);
could i have done something wrong in the code?
|
|
|
|
|
Member 12287337 wrote: could i have done something wrong in the code?
Possibly, but you have definitely done something wrong by pasting this in the Database forum - It probably belongs in the C# forum[^]
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
|
When you get a NullReferenceException you have to look at the line where it occurs and ask yourself: What could be null here that shouldn't be null? There are two variables involved: TextBox1 and s . TextBox1 could be null but you probably have let it "set up" for you by the designer so it's unlikely. That leaves s. Have you initialized s with an instance of its class Sales, something like Sales s = new Sales(); ?
Edit: Yes, you have. Sorry, I completely missed it.
So then run your App in debug mode and when you hit that line where the exception occurs inspect all variables on that line to find out which one is null.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
modified 2-Feb-16 7:17am.
|
|
|
|
|
Sascha Lefèvre wrote: Have you initialized s with an instance of its class Sales, something like Sales s = new Sales(); ?
He states so in the OP.
Member 12287337 wrote: in my .aspx.cs file i have created an object of the class in this case :
Sales s = new Sales ();
|
|
|
|
|
My bad :/
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
No worries, you're talking to an expert in misreading specs.
|
|
|
|
|
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Member 12287337 wrote: could i have done something wrong in the code? Yes quite a few in fact. Firstly you should not use float values in financial calculations, use Int or Decimal types. Secondly do not try to convert a float/decimal value into an integer, it will fail. Thirdly, do not use Convert.Toxxx as you have no idea what the user has typed into the textbox; use xxx.TryParse .
As to the NullReferenceException , you need to show exactly where it occurs in your code.
|
|
|
|
|
how are you all.
i am new to asp.net and c#. i need help.
well my question is, i have a textbox in which a user have to enter a float value in the webform.
and i want to manipulate that value in a calculation.
so have created a class for the calculation which is Sales class. in that class i have declared Price as a float value,the value which should be obtained from the textbox.ie public float Price {get;set;}
Now my problem is with binding/linking the Price variable with the textbox in the button_click method.
initially i had done it this way:
in my .aspx.cs file i have created an object of the class in this case :
Sales s = new Sales ();
protected void button_Click (object sender EventArgs e)
{
s.Price =Convert.ToInt32(Textbox1.Text);
s.Save();
}
i want the Price value to be saved in my database after a user clicks the SAVE button from the webform.
Now the problem is when i run the application there is an error (
An exception of type 'System.NullReferenceException' occurred in Version1.dll but was not handled in user code )
on the line :
s.Price = Convert.ToInt32(Textbox1.Text);
could i have done something wrong in the code?
|
|
|
|
|
Hi,
I want to ask what's the best way to store images in MySQL size-wise and performance-wise? is it better to store it as blob or as base64 text?
Thanks,
Jassim[^]
Technology News @ www.JassimRahma.com
|
|
|
|
|
Don't store file data in the database, store it in the file system and have the file name in the database only. Just my 2c!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If it is relational data, then it should be in the datastore
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Converting your blob yo base64 will cost time, and the result would be somewhat bigger.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Here's[^] a research document from Microsoft on the subject.
The tl;dr is that it's size dependent.
For smaller files it's better using a database, for larger files it's better using the file system. And the breakeven is somewhere around 0.1 - 1 MB, depending on your system. Possibly larger nowadays since there has been a bit of development since the paper was written.
|
|
|
|
|
Long story short, after reviewing server statistics after a large data conversion, I noticed that parameterized queries were being stored in plan cache thousands of times. Isn't parametrizing your queries supposed to prevent that?
Example offending query:
INSERT INTO AddressTable (ObjectId, IsMailing, Street1, Street2, City, State, PostalCode, County, Country)
VALUES (@ObjectId, @IsMailing, @Street1, @Street2, @City, @State, @PostalCode, @County, @Country);
The ObjectId is a Foreign Key (INT), IsMailing is a boolean (BIT), and the rest are NVARCHAR(X).
There were 38K+ records inserted into the table (one at a time) and there are ~3400 plans of this query cached in the plan cache. The conversion procedure is a custom application written in C# that generates the insert statements on the fly depending on what is being inserted but all the ad-hoc queries are identical for a given table. On a side note, the program was executing statements against the database across 70 to 80 separate threads concurrently (yay multi-threading).
Basically, my question is why would identical parameterized queries executed thousands of times create thousands of separate query plans? And is there any settings to change to prevent that?
if (Object.DividedByZero == true) { Universe.Implode(); }
|
|
|
|
|
Let me guess, you're using AddWithValue() for your parameters?
You should NEVER do that in production code.
There will be a real parameter created from it where the settings of type and length will be taken from the object supplied.
In other words, you'll get a new plan for every new length of an @address or @street and so on.
Create proper parameters where the types and lengths are specified according to the fields in the tables.
More info here[^].
|
|
|
|
|
Not at all. Here's the watered down, abreviated version of the code that generates the INSERT statement. There's a lot more going on but this is the meat of it.
List<string> columns = new List<string>();
List<string> variables = new List<string>();
string sqlStatement = null;
using (SqlCommand command = new SqlCommand() { CommandType = CommandType.Text, Connection = connection })
{
foreach (IProperty prop in IData.Properties)
{
columns.Add(prop.TableColumnName);
variables.Add("@" + prop.TableColumnName);
var currentParameter = new Parameter("@" + prop.TableColumnName, prop.SqlType);
currentParameter.Value = (objProp.Value == null) ? DBNull.Value : objProp.Value;
command.Parameters.Add(currentParameter);
}
sqlStatement = String.Join(" ", new string[]
{
"INSERT INTO dbo." + IData.TableName,
"(" + String.Join(", ", columns.ToArray()) + ")",
"VALUES (" + String.Join(", ", variables.ToArray()) + ");"
});
command.CommandText = sqlStatement;
command.ExecuteNonQuery();
}
if (Object.DividedByZero == true) { Universe.Implode(); }
|
|
|
|
|