Click here to Skip to main content
15,903,622 members
Home / Discussions / C#
   

C#

 
QuestionProblem in EventHandling Pin
Satish324-Dec-05 19:58
Satish324-Dec-05 19:58 
AnswerRe: Problem in EventHandling Pin
S. Senthil Kumar5-Dec-05 4:11
S. Senthil Kumar5-Dec-05 4:11 
Questionbin and obj folder in C# windows application Pin
nbobby4-Dec-05 19:27
nbobby4-Dec-05 19:27 
AnswerRe: bin and obj folder in C# windows application Pin
Heath Stewart4-Dec-05 19:47
protectorHeath Stewart4-Dec-05 19:47 
GeneralRe: bin and obj folder in C# windows application Pin
nbobby4-Dec-05 20:11
nbobby4-Dec-05 20:11 
AnswerRe: bin and obj folder in C# windows application Pin
har04mich5-Dec-05 6:52
har04mich5-Dec-05 6:52 
Questionurgent Help on C# Pin
momoo4-Dec-05 19:24
momoo4-Dec-05 19:24 
AnswerRe: urgent Help on C# Pin
Heath Stewart4-Dec-05 19:40
protectorHeath Stewart4-Dec-05 19:40 
First of all, never use string concatenation like that in SQL strings. All I have to do as an attacker is set the TBDate1.Text field (either in the page or via an HTTP GET or POST) to ' or 1=1; delete from Particulars; -- and your table is gone. With probing I could do worse, such as steal credit card information or other private information, etc. This is called a SQL injection attack and is one of the most overlooked vulnerabilities. Use parameterized queries using the SqlCommand.Parameters collection property.

That's also the answer to the problem here. Dates are typically surrounded by "#" (depending on the database management system) but using parameters eliminates having to know that:
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT * FROM Particulars WHERE DateField = @Date";
cmd.Parameters.Add("@Date", SqlDbType.DateTime).Value = DateTime.Parse(TBDate1.Text);
// ...
Add some error-handling, though, since DateTime.Parse could fail if incorrectly formatted.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft

[My Articles] [My Blog]
Questionreferring to Class Instance from other page Pin
vikings4-Dec-05 17:46
vikings4-Dec-05 17:46 
AnswerRe: referring to Class Instance from other page Pin
Heath Stewart4-Dec-05 19:34
protectorHeath Stewart4-Dec-05 19:34 
GeneralRe: referring to Class Instance from other page Pin
vikings4-Dec-05 19:50
vikings4-Dec-05 19:50 
GeneralRe: referring to Class Instance from other page Pin
Heath Stewart4-Dec-05 20:05
protectorHeath Stewart4-Dec-05 20:05 
AnswerRe: referring to Class Instance from other page Pin
nbobby4-Dec-05 19:46
nbobby4-Dec-05 19:46 
GeneralRe: referring to Class Instance from other page Pin
vikings4-Dec-05 19:52
vikings4-Dec-05 19:52 
GeneralRe: referring to Class Instance from other page Pin
Heath Stewart4-Dec-05 20:08
protectorHeath Stewart4-Dec-05 20:08 
GeneralRe: referring to Class Instance from other page Pin
nbobby4-Dec-05 20:18
nbobby4-Dec-05 20:18 
GeneralRe: referring to Class Instance from other page Pin
Heath Stewart4-Dec-05 20:23
protectorHeath Stewart4-Dec-05 20:23 
GeneralRe: referring to Class Instance from other page Pin
vikings4-Dec-05 20:43
vikings4-Dec-05 20:43 
GeneralRe: referring to Class Instance from other page Pin
nbobby4-Dec-05 22:55
nbobby4-Dec-05 22:55 
QuestionTopMost property of a form Pin
Ruskin Dantra4-Dec-05 10:22
Ruskin Dantra4-Dec-05 10:22 
AnswerRe: TopMost property of a form Pin
ekynox4-Dec-05 12:42
ekynox4-Dec-05 12:42 
GeneralRe: TopMost property of a form Pin
Ruskin Dantra4-Dec-05 13:40
Ruskin Dantra4-Dec-05 13:40 
AnswerRe: TopMost property of a form Pin
Luis Alonso Ramos5-Dec-05 6:20
Luis Alonso Ramos5-Dec-05 6:20 
GeneralRe: TopMost property of a form Pin
Ruskin Dantra5-Dec-05 11:38
Ruskin Dantra5-Dec-05 11:38 
GeneralRe: TopMost property of a form Pin
Luis Alonso Ramos5-Dec-05 15:54
Luis Alonso Ramos5-Dec-05 15:54 

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.