|
And, please, tell me what exactly an oznacenie is.
Guessing by Google images, it may be a sign
And from the clouds a mighty voice spoke: "Smile and be happy, for it could come worse!"
And I smiled and was happy And it came worse.
|
|
|
|
|
In this case it is something like "marking". Stupid naming in former developer's native language is next horrifying issue.
|
|
|
|
|
True. I would think that 'select count(*) from data where oznacenie like @data limit 1' (or count(oznacenie)) would be the most efficient way, though. There's no reason to make the database build up a full result set since you're just checking if anything is present and throwing away the data reader.
|
|
|
|
|
Or better yet:
SELECT TOP 1 0 FROM data WHERE oznacenie LIKE @OZ
Somebody in an online forum wrote: INTJs never really joke. They make a point. The joke is just a gift wrapper.
|
|
|
|
|
Is top better than limit? Or just a different way of writing the same thing?
|
|
|
|
|
I think limit is more flexible, but limit isn't available in SQL Server.
Somebody in an online forum wrote: INTJs never really joke. They make a point. The joke is just a gift wrapper.
|
|
|
|
|
But you still haven't addressed the shame! The potential of dragging thousands of records across the network. I'd be taking advantage of the ExecuteScalar method and the SQL COUNT function to address this issue.
Dim commandText = String.Format("SELECT COUNT(*) FROM data WHERE oznacenie LIKE '{0}'", data)
Int32 count = (Int32) cmd.ExecuteScalar() ;
Shame on you
"You get that on the big jobs."
|
|
|
|
|
It is true that i did not optimized SQL command, only removed worst trash from code. It is hundreds of records at maximum and it is not over network - only locally using SQL Server Compact Edition.
|
|
|
|
|
Select Count(*) has to do the fuzzy like search on the whole table just to show rows that match might exist - so it will probably do a full table scan (if start of like is a %)
better is to let SQL return as soon as it has found one row that matches - so use exists - e.g.
String.Format("SELECT 1 WHERE EXISTS (SELECT 1 FROM data WHERE oznacenie LIKE '{0}')", data)
That way SQL can stop looking after the first row it finds that matches. Depending on size of table this can make a huge difference in performance. This will return 0 or 1 records to the rowcount which you can get using ExecuteScalar return
|
|
|
|
|
Love that...
|
|
|
|
|
var cn = New System.Data.SqlServerCe.SqlCeConnection("Data Source=" + values.DatabaseFile);
cn.Open();
var cmd = New System.Data.SqlServerCe.SqlCeCommand("SELECT Count(ID_COL) FROM data where oznacenie like '" + data + "'", cn);
var count = cmd.ExecuteScalar();
this seems to be an optimized solution to me, shouldn't use '*' if we can do without it cause you don't know what kind of nutter designed the database. I have seen tables with 45 columns that slows down the query. Always prefer to specify exact columns I need in the queries.
|
|
|
|
|
if (currentRadioButton.Checked == false) return;
{
ViewManager.ShowOutputForm(this.ParentForm.MdiParent, eOutputForm);
InitRiskReturnToolWindow(m_eMode);
}
Doesn't actually cause an error, but the GALL of someone to leave that in MY codebase....
|
|
|
|
|
My eyes slipped right by the "return" at first. That's just... unnatural.
|
|
|
|
|
I know. Look forward to more of these from me over the next few months as I wrest this codebase into something resembling a proper application....
|
|
|
|
|
Wow! That's something really new here!
A very nice way to obfuscate code.
|
|
|
|
|
I'm always in search for obfuscate code.
|
|
|
|
|
I read it once and was like 'Huh, what's the problem?'. And then I saw it. That's the sign of a true horror.
I don't think this even gives a warning in C# because the if is fully formed and bracing for scope is fine.
|
|
|
|
|
BobJanova wrote: That's the sign of a true horrorprankster. FTFY
Oxfords English < Official CCC Players Dictionary
Excuse me for my improper grammar and typos.
It's because English is my primary language, not my first language.
My first languages are C# and Java.
VB, ASP, JS, PHP and SQL are my second language.
Indonesian came as my third language.
My fourth language? I'm still creating it, I'll let you know when it's done!
|
|
|
|
|
This is one of the reasons why I always brace single line if statements - it is too easy to miss what is happening especially if someone or something (code prettifiers etc) mangle the code like you have found.
|
|
|
|
|
That is a work of art!
|
|
|
|
|
Names changed to protect the innocent....
private void FillGrid()
{
}
private void Case_SelectionChanged(object sender, EventArgs e)
{
FillGrid();
}
private void FillCase(string PatientID)
{
case.ItemIndex = 0;
}
protected void Search()
{
FillCase(PatientID);
case.EditValue = caseNo.Trim();
Case_SelectionChanged(new object(), new EventArgs());
FillGrid();
}
So, in 4 lines of code in Search(), we call a lengthy FillGrid function 4 times....Really?
modified 25-Oct-11 12:06pm.
|
|
|
|
|
That example is not complete, is it? All of the functions you show are private/protected, none is public, and only one gets called by a user interaction. The real fun must be somewhere else. Didn't you see a function like:
private void Button1_Click(object sender, EventArgs e)
{
FillCase("");
Search();
Case_SelectionChanged(new object(), new EventArgs());
FillGrid();
FillCase("some value");
Search();
Case_SelectionChanged(new object(), new EventArgs());
FillGrid();
... and some more lines of code
}
|
|
|
|
|
He just wanted to be on the safe side and assured that the grid is filled, no matter what happens
And from the clouds a mighty voice spoke: "Smile and be happy, for it could come worse!"
And I smiled and was happy And it came worse.
|
|
|
|
|
From what I can see the grid won't actually be filled if the FillGrid throws an Exception. Unless there is a deleted try catch block there that recursively calls the FillGrid Method again in its catch block...
It's an OO world.
public class Naerling : Lazy<Person>{}
|
|
|
|
|
Did you got the guy fired, cause of such guys the software can't cope up even with hardware advancements. Even with a quad core machines and GBs of RAM we still have the same performance issues we used to have in the days of Pentium I and a few MB of RAM.
|
|
|
|