|
Ouch. Are you the guy who wrote the copy folder algorithm for Vista?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Ninja-the-Nerd wrote: VB6
I think Chris could as well redirect all Visual Basic posts to the coding horror forum
Constantly "Saving the day" should be taken as a sign of organizational dysfunction rather than individual skill - Ryan Roberts[^]
|
|
|
|
|
And all VB articles to Purgatory, pending portation to C#?
It's not that bad. It's simple enough for people like me to use it, and there's so many inefficient C based programs it's becoming hard to tell the difference :-P.
I'll have another one soon, I'm porting and completing the VB6 version to VB .NET which should be a right laugh. At least I intend to use GDI for it this time, and use some optimised methods of dropping images.
If any of my future employers see this...[crosses fingers]
"Yes boss, I learned from my mistake"
"No boss, I haven't learned C++"
Yet another spam post on yet another forum!
I am the lazy one, who sleeps as it suits him, codes what he wishes, and has many years to look forward to.
I love being a student.
|
|
|
|
|
C# ones, often, aren't that better.
-- modified at 10:18 Thursday 24th May, 2007
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Gruesome.
Guess that's why we have the ability to write Active-X controls in VC?
|
|
|
|
|
VB6 for a game, isnt it to slow. VB6 is outdated I think you should upgrade yourself at least to VB.net or a real programming language.
"Carpe diem"
Greetings from Germany
|
|
|
|
|
That is just the learning process. If we did not make mistakes then we would not learn anything or for that matter – get anything done.
Programmers point of view:
1) Think.
2) Write something based on ideas.
3) Note possible problems – Think.
4) Rewrite – based on what you learned.
5) Think – are you satisfied (learned enough).
6) Make notes – consider improvements.
Management point of view:
1) Think.
2) Write something based on ideas.
3) Does it work?
4) If yes! You are finished – because it works.
5) Stop thinking – for self preservation of sanity.
6) Recommendation – make personal notes – and go on to next subject.
Note: If you do not inform management until step 4 in “Programmers point of view" is complete then you will have a better (more reliable) product. But if you must show progress based on the “Management point of view” then expect to be cut off at the knees, and learn to live with it.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Today I was looking through the code of
student who is working on some project for our company.
He's trying to make a new user admininstration application.
In his application he is loading the users from the database in a treeview.
Ok, so far so good. Nothing is wrong.
Now I've tried to load the user informations and wondered why the data didn't
match to the selected user.
The following code snippet is the reason.
<br />
string query = "ID = " + this.userTree.SelectedNode.Index.ToString();<br />
DataRow[] foundi = tableAdapterUsers.Select(query);<br />
He's making a Select on the Database expecting that
the TreeViewID is equal the Database ID.
I spend the nearly the whole morning to find this.
I'm wishing everbody a nice weekend
greetings
pdluke
|
|
|
|
|
Youch. When I build TreeNode s from DataRow s I store the original DataRow in the Tag field of the TreeNode for future reference.
|
|
|
|
|
pdluke wrote: string query = "ID = " + this.userTree.SelectedNode.Index.ToString();
It is interesting to see people make sql queries this way and expose themselves to SQL injections. Parameterized queries are not only safer, but also easier, IMHO.
|
|
|
|
|
Nemanja Trifunovic wrote: Parameterized queries are not only safer, but also easier
I'm not suggesting I agree with the method shown in by the OP, but it is much easier to keep a source history if the queries are in the code rather than stored procedures and also less likely to miss an update when releasing a new version of code.
That said, i use parameterized queries
Pualee
|
|
|
|
|
You don't have to use stored procedures to use parameterized queries, just put parameters in your queries.
"ID = @id" instead of "ID = '" + id.ToString() + "'"
Using the GridView is like trying to explain to someone else how to move a third person's hands in order to tie your shoelaces for you.
-Chris Maunder
|
|
|
|
|
Pualee wrote: if the queries are in the code rather than stored procedures
I never mentioned stored procedures . Parameterized queries can be kept in the source code.
|
|
|
|
|
For me, writing on this forum is always a tradeoff between looking stupid and learning more...
Thanks for the clarification
|
|
|
|
|
We use Stored Procedures at the organization I work for, but they have to be created in VS (which is under Source Control) before they can be created on the test database (with each release we submit release notes with files we've modified, created or removed and the person responsible for the builds handles it from there) that way the stored procedures are also under source control.
"Okay, I give up: which is NOT a real programming language????"
Michael Bergman
"Well yes, it is an Integer, but it's a metrosexual Integer. For all we know, under all that hair gel it could be a Boolean."
Tom Welch
"Let's face it, the average computer user has the brain of a Spider Monkey."
Bill Gates
|
|
|
|
|
Or.... just write a function to check all your input fields before processing them? Little things... like making sure numeric values are in "int" and strings are properly quoted out and escaped before concatenating the final SQL string works fine too. Just gotta be careful.
|
|
|
|
|
First code snippet
<br />
for(int i=1;i<=100;i++)<br />
DropDownList1.Items.Add(new ListItem(i.ToString(),i.ToString()));<br />
Second Code Snippet
<br />
DropDownList1.Items.Add(new ListItem("1","1"));<br />
DropDownList1.Items.Add(new ListItem("2","2"));<br />
DropDownList1.Items.Add(new ListItem("3","3"));<br />
DropDownList1.Items.Add(new ListItem("4","4"));<br />
DropDownList1.Items.Add(new ListItem("5","5"));<br />
DropDownList1.Items.Add(new ListItem("6","6"));<br />
DropDownList1.Items.Add(new ListItem("7","7")); <br />
DropDownList1.Items.Add(new ListItem("8","8")); <br />
.<br />
.<br />
.<br />
.<br />
DropDownList1.Items.Add(new ListItem("99","99")); DropDownList1.Items.Add(new ListItem("100","100"));<br />
<br />
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|
|
not really the right forum for this.
but.
methink the first alternative is the simplest, the fasted and can be the easiest to maintain in the long run.
|
|
|
|
|
If you'd posted the second as an example of what somebody has done then I would say this was a perfect coding horror.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
It happened long time back with one of my friend, He was working in a company and his colleague wrote all hundred lines of code to populate drop down listbox.
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|
|
I can see how this could be done in a script language, where there is no benefit to keeping the data outside of the application, i.e. actually use the multiple statements to define the content of the list.
|
|
|
|
|
sylvesterg wrote: wrote all hundred lines of code to populate drop down listbox.
And if that is JavaScript, the amount of page size (ViewSource) that travels down the Internet pipe is really phenomenal.
|
|
|
|
|
The first one is much better coding.
The second one I would predict to be a nanosecond or something faster.
The reason being the first one has to create a loop, some tostrings, an int etc....
And it still creates the same ammount of listitems, and such.
The second on would make a larger dll, but probably execute a smidget faster cause of less resources..... but.... NEVER EVER DO THAT unless you have like 2 items or something small and ridicuous.
The performance difference is not even close to being worth the pain of working on code like that.
So... for(...) wins hands down.
http://www.jonavi.com
|
|
|
|
|
There's usually an unroll-loop option in most compilers.
|
|
|
|
|
The first one is certainly slower, since the compiler will have to evaluate two additional commands for every loop... but is certainly better in terms of maintainability.
|
|
|
|