Hot answers tagged

43 votes
Accepted

Extensible code to support different HR rules

I coded keeping SOLID principle in mind and here is my code. What did I miss? Let's see... SRP - Single Responsibility Principle A class should have only one reason to change. Violated. The name ...
t3chb0t's user avatar
  • 44.2k
33 votes

Login form C# SQL

SQL Injection alarm Don't use user passed text in your sql statements if you aren't using parameters. From: https://stackoverflow.com/a/7505842/2655508 Using parameters helps prevent SQL Injection ...
Heslacher's user avatar
  • 50.4k
27 votes
Accepted

Simplifying constructing native SQL query with nested if-else's

Let's look for some patterns in your code: First of all, we notice that you have three parameters with similar names. condition, ...
Simon Forsberg's user avatar
20 votes
Accepted

Where are my downvotes?

If this is actually your first SQL you're quite good in learning new languages. Some remarks: The Group By is not weird, it's the ...
dnoeth's user avatar
  • 1,172
18 votes

Login form C# SQL

Cleartext passwords Not a code-specific issue exactly but it would appear that you are storing the user's passwords in clear text. This means that anyone gaining access to the LOGIN_Tab would be ...
motosubatsu's user avatar
17 votes

Extensible code to support different HR rules

public class EmployeeLeave : ILeaveRequest ... var leaveRequest = new EmployeeLeaveDetail(); This is confusing. Going by name, ...
404's user avatar
  • 2,306
16 votes

Login form C# SQL

In addition to Heslacher's answer I would also look at the using statement. It is very important to keep a handle on resources like Sql Connections to ensure they ...
Geek's user avatar
  • 439
14 votes

Extensible code to support different HR rules

catch (Exception) { throw; } Well this won't buy you anything but a few more lines of code. Just remove the try..catch ...
Heslacher's user avatar
  • 50.4k
14 votes
Accepted

A wounded Zombie finder, or: how to find the almost dead undead?

Not utterly wrong, but q.PostTypeId = 1 and AND a.PostTypeId = 2 are superfluous. The only post types with a non-null ...
Glorfindel's user avatar
  • 1,089
13 votes
Accepted

Stack Exchange User Activity Score

TOP 1 When selecting values that correspond to Unique fields referenced by constants (OwnerUserId), you're only really ...
Quill's user avatar
  • 11.9k
13 votes
Accepted

Wrapper for commonly used database classes

First of all, it's unclear to me what exactly you want to achieve with this code. Database access, yes, but what benefits should your code provide? Why don't you want to use ...
Pieter Witvoet's user avatar
12 votes

Login form C# SQL

Security issues are covered, so just a bit on the code itself. You have three nearly identical pieces of code, inside a switch-statement. That seems to be a code-smell. Apart from that, I'm missing a ...
oerkelens's user avatar
  • 396
11 votes
Accepted

Deleting millions of rows from a MSSQL server table

The performance problem is due to the non-sargable expression YEAR(CREATEDATE). Applying a function to a column in a WHERE clause prevents efficient use of the ...
Dan Guzman's user avatar
11 votes
Accepted

SQL database for a social network

Generally speaking, the schema looks good and well organized, however a few columns could use some refactoring. Here is what I can point to. Users table ...
Alejandro's user avatar
  • 494
10 votes
Accepted

Query to count interactions between users

Before we begin with the code... I just want to address one thing regarding test cases with sample data. To get the best out of a performance review of your queries, try to provide a sample that's as ...
Phrancis's user avatar
  • 20.4k
10 votes

Login form C# SQL

using as already covered SQL injection as already covered For getting a single row Reader is more efficient than ...
paparazzo's user avatar
  • 5,946
10 votes
Accepted

Code which pulls from SQL and dumps in Excel

First of all let me make an important comment not related to performance: Security issues I hope your table is only accessible by by a limited number of trusted people. I say this because building a ...
M.Doerner's user avatar
  • 1,490
10 votes
Accepted

SQL trigger to log when employee records are updated

First some comments. Usage of Deprecated Features Currently your trigger does a SELECT that returns a resultset from a trigger. That was at one time supported but ...
this's user avatar
  • 2,019
10 votes
Accepted

Searching for a word in a list of tuple extracted from a db via SQL

You could try doing the filtering at the database level. Something like: ...
defy's user avatar
  • 306
10 votes

Reorganizing unorthodox PHP phone book project

Your project looks nice, and the design of your web page is good. There were a few points I spotted with the code that are well worth taking note of. Security While security may sound less important ...
htl's user avatar
  • 546
10 votes
Accepted

Reorganizing unorthodox PHP phone book project

Security Security is super important. In 2020 it is not acceptable to write code that is blatantly vulnerable to SQL injection. Start taking good habits today. Even if you are lazy and you are the ...
Kate's user avatar
  • 6,400
9 votes
Accepted

Replacement for sp_MSforeachdb

First off, please heed the advice from @Zak about Version Control System (VCS). That should be the first take-away from this. Slashy comment block You have 31 lines, 4462 characters of slashy ...
Phrancis's user avatar
  • 20.4k
9 votes

Simple login page

✔ Binding parameters You're using a database API and successfully binding your parameters. This will prevent SQL injection. ✘ No character white-lists Since you're outputting user input (ie: ...
ʰᵈˑ's user avatar
  • 336
9 votes
Accepted

SQL query to compare two XML columns

Try this query instead on your data and tell how it performs. Not sure it will return exactly the same as your query but it should be close enough so you can adjust to what you want. ...
Mikael Eriksson's user avatar
9 votes

Extensible code to support different HR rules

A lot of useful comments is here but no-one has commented about the usage of DateTime. EmployeeLeave ...
Paweł Łukasik's user avatar
9 votes

SQL query to find expenditures of employees who have exceeded their limit

Let's assume that your table declarations look like this and that you're using MySQL 8.0: ...
Reinderien's user avatar
  • 60.8k
8 votes

Find & Delete Duplicate Records on All Tables in current MSSQL Database

You started out with all your keywords being capitalized and then you abandoned your capitalization haphazardly throughout the script, this makes it a little hard to read because your brain says that ...
Malachi's user avatar
  • 28.6k
8 votes
Accepted

MySQL homeowner database

For the table definitions, just use an INT for the keys. You probably aren't saving anything by using SMALLINTs. Schema ...
200_success's user avatar
8 votes

SharePoint CRUD class

As per the Microsoft Guidelines, properties use PascalCase. Following line: public string name { get; set; } becomes: ...
Abbas's user avatar
  • 5,553
8 votes

Extensible code to support different HR rules

Generally speaking, unit tests should follow the "Arrange, Act, Assert"-pattern. Yours only have the "Arrange, Act"-part. You're not asserting anything (with the exception of the one where you're ...
germi's user avatar
  • 488

Only top scored, non community-wiki answers of a minimum length are eligible