Click here to Skip to main content
15,867,453 members
Home / Discussions / C#
   

C#

 
GeneralRe: updating MS database using c#.net Pin
Eng.almasrouhi11-Mar-13 12:13
Eng.almasrouhi11-Mar-13 12:13 
AnswerRe: updating MS database using c#.net Pin
jschell12-Mar-13 9:21
jschell12-Mar-13 9:21 
Questionerror with update query Pin
User349011-Mar-13 9:23
User349011-Mar-13 9:23 
AnswerRe: error with update query Pin
vanikanc11-Mar-13 9:31
vanikanc11-Mar-13 9:31 
GeneralRe: error with update query Pin
User349011-Mar-13 9:36
User349011-Mar-13 9:36 
GeneralRe: error with update query Pin
vanikanc11-Mar-13 10:13
vanikanc11-Mar-13 10:13 
GeneralRe: error with update query Pin
susanna.floora12-Mar-13 0:11
susanna.floora12-Mar-13 0:11 
AnswerRe: error with update query Pin
Dave Kreskowiak11-Mar-13 10:12
mveDave Kreskowiak11-Mar-13 10:12 
First and foremost, you do NOT use string concatentation to built a query like that. Why? Just Google for "SQL Injection attack" and you'll find out. A big problem with what you've done is what happens if the user types a ' character in their password?? I guarantee that it'll break your code and give you the error that you're talking about.

Then you can Google for "C# SQL Parameterized queries" to find out how to do it correcly. This also has the benefit of making your code easier to debug and maintain.

Next, why are you calling .ToString() on a string?? The Text property always returns a string, so there's no need to call .ToString() on it!


And finally, with an UPDATE statement as yours, you would normally use ExecuteScalar, no ExecuteReader, to launch it.

GeneralRe: error with update query Pin
User349011-Mar-13 11:21
User349011-Mar-13 11:21 
GeneralRe: error with update query Pin
Dave Kreskowiak11-Mar-13 12:33
mveDave Kreskowiak11-Mar-13 12:33 
GeneralRe: error with update query Pin
User349011-Mar-13 13:17
User349011-Mar-13 13:17 
QuestionWMI remote call Pin
vanikanc11-Mar-13 7:35
vanikanc11-Mar-13 7:35 
AnswerRe: WMI remote call Pin
Dave Kreskowiak11-Mar-13 10:05
mveDave Kreskowiak11-Mar-13 10:05 
GeneralRe: WMI remote call Pin
vanikanc11-Mar-13 10:29
vanikanc11-Mar-13 10:29 
QuestionOpenoffice Impress using C# Pin
Sachin k Rajput 11-Mar-13 1:43
Sachin k Rajput 11-Mar-13 1:43 
AnswerRe: Openoffice Impress using C# Pin
Richard MacCutchan11-Mar-13 1:49
mveRichard MacCutchan11-Mar-13 1:49 
GeneralRe: Openoffice Impress using C# Pin
Sachin k Rajput 11-Mar-13 2:21
Sachin k Rajput 11-Mar-13 2:21 
GeneralRe: Openoffice Impress using C# Pin
Richard MacCutchan11-Mar-13 2:51
mveRichard MacCutchan11-Mar-13 2:51 
AnswerRe: Openoffice Impress using C# Pin
Eddy Vluggen11-Mar-13 3:32
professionalEddy Vluggen11-Mar-13 3:32 
Questionslope of a line Pin
Naman200710-Mar-13 22:32
Naman200710-Mar-13 22:32 
AnswerRe: slope of a line Pin
Abhinav S10-Mar-13 22:38
Abhinav S10-Mar-13 22:38 
GeneralRe: slope of a line Pin
Naman200710-Mar-13 22:47
Naman200710-Mar-13 22:47 
AnswerRe: slope of a line Pin
Abhinav S10-Mar-13 22:57
Abhinav S10-Mar-13 22:57 
GeneralRe: slope of a line Pin
harold aptroot11-Mar-13 2:41
harold aptroot11-Mar-13 2:41 
GeneralRe: slope of a line Pin
Naman200713-Mar-13 4:34
Naman200713-Mar-13 4:34 

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.