Click here to Skip to main content
15,892,809 members
Home / Discussions / C#
   

C#

 
AnswerRe: Restore fingerprint data for timekeeper Ronald jack x628-C ? Pin
OriginalGriff25-Mar-19 22:54
mveOriginalGriff25-Mar-19 22:54 
QuestionExport from DataGridView to access _ c# Pin
Member 1419439024-Mar-19 12:15
Member 1419439024-Mar-19 12:15 
AnswerRe: Export from DataGridView to access _ c# Pin
josda100024-Mar-19 15:41
josda100024-Mar-19 15:41 
AnswerRe: Export from DataGridView to access _ c# Pin
OriginalGriff24-Mar-19 21:10
mveOriginalGriff24-Mar-19 21:10 
GeneralRe: Export from DataGridView to access _ c# Pin
Member 1419439024-Mar-19 22:11
Member 1419439024-Mar-19 22:11 
GeneralRe: Export from DataGridView to access _ c# Pin
OriginalGriff24-Mar-19 22:40
mveOriginalGriff24-Mar-19 22:40 
QuestionQuestion about login form with access database Pin
Member 1114879324-Mar-19 1:42
Member 1114879324-Mar-19 1:42 
AnswerRe: Question about login form with access database Pin
OriginalGriff24-Mar-19 2:03
mveOriginalGriff24-Mar-19 2:03 
Before you start moving on to levels and rules, you have got to fix that first - it's very bad code.
1) Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Always use Parameterized queries instead.

When you concatenate strings, you cause problems because SQL receives commands like:
SQL
SELECT * FROM MyTable WHERE StreetAddress = 'Baker's Wood'
The quote the user added terminates the string as far as SQL is concerned and you get problems. But it could be worse. If I come along and type this instead: "x';DROP TABLE MyTable;--" Then SQL receives a very different command:
SQL
SELECT * FROM MyTable WHERE StreetAddress = 'x';DROP TABLE MyTable;--'
Which SQL sees as three separate commands:
SQL
SELECT * FROM MyTable WHERE StreetAddress = 'x';
A perfectly valid SELECT
SQL
DROP TABLE MyTable;
A perfectly valid "delete the table" command
SQL
--'
And everything else is a comment.
So it does: selects any matching rows, deletes the table from the DB, and ignores anything else.

So ALWAYS use parameterized queries! Or be prepared to restore your DB from backup frequently. You do take backups regularly, don't you?

2) Never store passwords in clear text - it is a major security risk. There is some information on how to do it here: Password Storage: How to do it.[^]

3) Don't hardcode connections strings. If you do, then you have to change your code and rebuild for release, and potentially for every different installation. Use a configuration file instead, so it;s easy to update without changing your code.

4) Don't use SELECT * FROM ... - always name the columns you want to return. In this case, SELECT COUNT(User) FROM ... would have been sufficient. You are returning information you already have and that's wasteful. It's not a problem right now, but it will be in "real world" apps so it's worth getting into the habit of doing it correctly from the beginning.

5) Don't use a DataAdapter to return a single piece of info: use ExecuteScalar instead, which returns a single value.

When you have fixed that lot, then think about moving forward.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!

QuestionMessage Removed Pin
23-Mar-19 12:08
Member 1419354023-Mar-19 12:08 
QuestionCzytanie z drukarki Posnet / Receive Posnet POS printer answer Pin
OraToraCora21-Mar-19 13:24
OraToraCora21-Mar-19 13:24 
AnswerRe: Czytanie z drukarki Posnet / Receive Posnet POS printer answer Pin
Luc Pattyn21-Mar-19 15:37
sitebuilderLuc Pattyn21-Mar-19 15:37 
GeneralRe: Czytanie z drukarki Posnet / Receive Posnet POS printer answer Pin
glennPattonWork325-Mar-19 6:39
professionalglennPattonWork325-Mar-19 6:39 
QuestionDecimal values input validation Pin
Rap Gutierrez21-Mar-19 2:31
professionalRap Gutierrez21-Mar-19 2:31 
AnswerRe: Decimal values input validation Pin
OriginalGriff21-Mar-19 3:31
mveOriginalGriff21-Mar-19 3:31 
AnswerRe: Decimal values input validation Pin
Member 230317321-Mar-19 21:26
Member 230317321-Mar-19 21:26 
AnswerRe: Decimal values input validation Pin
BillWoodruff22-Mar-19 19:47
professionalBillWoodruff22-Mar-19 19:47 
AnswerRe: Decimal values input validation Pin
jschell23-Mar-19 5:42
jschell23-Mar-19 5:42 
GeneralRe: Decimal values input validation Pin
BillWoodruff23-Mar-19 6:24
professionalBillWoodruff23-Mar-19 6:24 
Questionprogramming Pin
Member 1419026720-Mar-19 12:41
Member 1419026720-Mar-19 12:41 
AnswerRe: programming Pin
Dave Kreskowiak20-Mar-19 15:51
mveDave Kreskowiak20-Mar-19 15:51 
AnswerRe: programming Pin
OriginalGriff20-Mar-19 21:03
mveOriginalGriff20-Mar-19 21:03 
GeneralRe: programming Pin
Ralf Meier20-Mar-19 22:17
mveRalf Meier20-Mar-19 22:17 
GeneralRe: programming Pin
OriginalGriff20-Mar-19 22:23
mveOriginalGriff20-Mar-19 22:23 
GeneralRe: programming Pin
Ralf Meier20-Mar-19 23:32
mveRalf Meier20-Mar-19 23:32 
GeneralRe: programming Pin
OriginalGriff20-Mar-19 23:42
mveOriginalGriff20-Mar-19 23:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.