Click here to Skip to main content
15,905,144 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: How to make the VB6 and MS-Access project Centralised? Pin
_Damian S_23-Aug-10 20:41
professional_Damian S_23-Aug-10 20:41 
GeneralRe: How to make the VB6 and MS-Access project Centralised? Pin
kokilag24-Aug-10 19:31
kokilag24-Aug-10 19:31 
GeneralRe: How to make the VB6 and MS-Access project Centralised? Pin
_Damian S_24-Aug-10 20:38
professional_Damian S_24-Aug-10 20:38 
GeneralRe: How to make the VB6 and MS-Access project Centralised? Pin
kokilag25-Aug-10 18:36
kokilag25-Aug-10 18:36 
GeneralRe: How to make the VB6 and MS-Access project Centralised? Pin
kokilag27-Aug-10 0:37
kokilag27-Aug-10 0:37 
QuestionMessage Removed Pin
23-Aug-10 11:37
kereljansen23-Aug-10 11:37 
AnswerRe: sql string Pin
Wes Aday23-Aug-10 12:32
professionalWes Aday23-Aug-10 12:32 
AnswerRe: sql string Pin
Luc Pattyn23-Aug-10 12:39
sitebuilderLuc Pattyn23-Aug-10 12:39 
your code has two problems:

1.
when tblocation.Text contains either nothing or some special characters (including single quote, double quote, parenthesis, ...) then your VB statement will happily concatenate everything, however it will not result in a valid SQL statement.

2.
when a malicious user enters some special stuff through tblocation.Text, the net result may be a valid SQL statement with side effects you don't want; by providing some text, a quote, a closing parenthesis, a semi-colon, then whatever follows would be executed as a second SQL statement, and could e.g. delete an entire table. This problem is known as "SQL injection attacks".

There are basically two solutions:

1.
the best one is using SqlParameter, which means no string concatenation is used holding user input; all user input is handled separately, see SqlCommand.AddParameter().
This approach solves both problems.

2.
check and filter the textbox input; make sure there is nothing you don't want. If you want to allow quotes (as required in your example), then you may have to resort to special encoding, e.g. you could double the character on insertion, telling the database engine a single quote is required in the data.

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.


GeneralRe: sql string Pin
Richard A. Dalton23-Aug-10 13:31
Richard A. Dalton23-Aug-10 13:31 
AnswerRe: sql string Pin
Luc Pattyn23-Aug-10 13:47
sitebuilderLuc Pattyn23-Aug-10 13:47 
Questionsaving document with passwords encrypted Pin
FeRtoll23-Aug-10 0:47
FeRtoll23-Aug-10 0:47 
AnswerRe: saving document with passwords encrypted Pin
Dave Kreskowiak23-Aug-10 3:42
mveDave Kreskowiak23-Aug-10 3:42 
AnswerRe: saving document with passwords encrypted Pin
Richard MacCutchan23-Aug-10 4:48
mveRichard MacCutchan23-Aug-10 4:48 
AnswerRe: saving document with passwords encrypted Pin
Mike Marynowski24-Aug-10 19:45
professionalMike Marynowski24-Aug-10 19:45 
QuestionString obfuscation and function names Pin
Atara22-Aug-10 23:21
Atara22-Aug-10 23:21 
AnswerRe: String obfuscation and function names Pin
Eduard Keilholz22-Aug-10 23:39
Eduard Keilholz22-Aug-10 23:39 
GeneralRe: String obfuscation and function names Pin
Atara22-Aug-10 23:43
Atara22-Aug-10 23:43 
GeneralRe: String obfuscation and function names Pin
Dave Kreskowiak23-Aug-10 3:35
mveDave Kreskowiak23-Aug-10 3:35 
GeneralRe: String obfuscation and function names Pin
Atara23-Aug-10 3:40
Atara23-Aug-10 3:40 
AnswerRe: String obfuscation and function names Pin
Former employee23-Aug-10 23:17
Former employee23-Aug-10 23:17 
GeneralRe: String obfuscation and function names Pin
Atara23-Aug-10 23:42
Atara23-Aug-10 23:42 
GeneralRe: String obfuscation and function names Pin
Mike Marynowski24-Aug-10 19:55
professionalMike Marynowski24-Aug-10 19:55 
GeneralRe: String obfuscation and function names Pin
Atara24-Aug-10 20:01
Atara24-Aug-10 20:01 
GeneralRe: String obfuscation and function names Pin
Mike Marynowski24-Aug-10 20:05
professionalMike Marynowski24-Aug-10 20:05 
AnswerRe: String obfuscation and function names Pin
LogicNP21-Sep-11 1:12
LogicNP21-Sep-11 1:12 

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.