Click here to Skip to main content
16,012,223 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# Mysql query problem Pin
Blue_Boy18-Jul-11 23:32
Blue_Boy18-Jul-11 23:32 
GeneralRe: C# Mysql query problem Pin
nighttrain_18-Jul-11 23:52
nighttrain_18-Jul-11 23:52 
SuggestionRe: C# Mysql query problem Pin
GuyThiebaut19-Jul-11 1:59
professionalGuyThiebaut19-Jul-11 1:59 
GeneralRe: C# Mysql query problem Pin
nighttrain_19-Jul-11 2:38
nighttrain_19-Jul-11 2:38 
GeneralRe: C# Mysql query problem Pin
GuyThiebaut19-Jul-11 3:05
professionalGuyThiebaut19-Jul-11 3:05 
AnswerRe: C# Mysql query problem Pin
PIEBALDconsult19-Jul-11 2:45
mvePIEBALDconsult19-Jul-11 2:45 
GeneralRe: C# Mysql query problem Pin
nighttrain_19-Jul-11 3:35
nighttrain_19-Jul-11 3:35 
AnswerRe: C# Mysql query problem [modified] Pin
BobJanova19-Jul-11 3:56
BobJanova19-Jul-11 3:56 
Firstly, if at all possible, you should use parameterised queries, and if not, you must escape the contents of those text boxes before creating the query string. At the moment, if those are free text boxes, there is a huge SQL injection hole in this code.

Secondly, you should be using a DateTimePicker or similar for the dates, and using myDateTimePicker.Value.ToString("yyyy-MM-dd") to get them in database format. Edit from the subthread below: If you are using parameterised queries, you should (of course) pass the date as a DateTime. The string formatting is only if you are building a query string. Ideally you should use a numeric text box type as well but inexplicably that doesn't exist in the standard framework.

Thirdly, I suspect the immediate cause of the problem is that the dates are not in a valid format. See what the string you are actually creating really looks like, and compare it to a static query that works.

modified on Thursday, July 21, 2011 1:02 PM

GeneralRe: C# Mysql query problem Pin
PIEBALDconsult19-Jul-11 14:22
mvePIEBALDconsult19-Jul-11 14:22 
GeneralRe: C# Mysql query problem Pin
BobJanova20-Jul-11 11:19
BobJanova20-Jul-11 11:19 
GeneralRe: C# Mysql query problem Pin
PIEBALDconsult20-Jul-11 14:18
mvePIEBALDconsult20-Jul-11 14:18 
GeneralRe: C# Mysql query problem Pin
BobJanova21-Jul-11 7:02
BobJanova21-Jul-11 7:02 
GeneralRe: C# Mysql query problem Pin
sugais19-Jul-11 20:51
sugais19-Jul-11 20:51 
GeneralRe: C# Mysql query problem [modified] Pin
nighttrain_20-Jul-11 5:43
nighttrain_20-Jul-11 5:43 
GeneralRe: C# Mysql query problem Pin
nighttrain_21-Jul-11 21:26
nighttrain_21-Jul-11 21:26 
QuestionHow to Finding Solutions Pin
Anubhava Dimri18-Jul-11 21:35
Anubhava Dimri18-Jul-11 21:35 
AnswerRe: How to Finding Solutions Pin
Blue_Boy18-Jul-11 22:02
Blue_Boy18-Jul-11 22:02 
GeneralRe: How to Finding Solutions Pin
Anubhava Dimri18-Jul-11 23:33
Anubhava Dimri18-Jul-11 23:33 
GeneralRe: How to Finding Solutions Pin
Blue_Boy18-Jul-11 23:36
Blue_Boy18-Jul-11 23:36 
GeneralRe: How to Finding Solutions Pin
Anubhava Dimri19-Jul-11 1:21
Anubhava Dimri19-Jul-11 1:21 
GeneralRe: How to Finding Solutions Pin
HTT9019-Jul-11 2:18
HTT9019-Jul-11 2:18 
AnswerRe: How to Finding Solutions Pin
BobJanova18-Jul-11 22:10
BobJanova18-Jul-11 22:10 
AnswerRe: How to Finding Solutions Pin
Estys18-Jul-11 22:32
Estys18-Jul-11 22:32 
GeneralRe: How to Finding Solutions Pin
Anubhava Dimri18-Jul-11 23:26
Anubhava Dimri18-Jul-11 23:26 
GeneralRe: How to Finding Solutions Pin
Estys18-Jul-11 23:43
Estys18-Jul-11 23:43 

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.