Click here to Skip to main content
15,796,456 members
Home / Discussions / C#
   

C#

 
PinnedHOW TO ANSWER A QUESTION PinPopular
Chris Maunder12-Jul-09 23:36
cofounderChris Maunder12-Jul-09 23:36 
PinnedHow to get an answer to your question Pin
Chris Maunder10-Nov-05 17:31
cofounderChris Maunder10-Nov-05 17:31 
Questionis there any way to get bordercolor same as candle color using ternary in the code below Pin
j k Nov202316hrs 20mins ago
j k Nov202316hrs 20mins ago 
QuestionC# code to chart sometimes charting blank charts Pin
Iskander1234530-Nov-23 17:01
Iskander1234530-Nov-23 17:01 
AnswerRe: C# code to chart sometimes charting blank charts Pin
Ralf Meier30-Nov-23 22:12
professionalRalf Meier30-Nov-23 22:12 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Iskander123451-Dec-23 1:52
Iskander123451-Dec-23 1:52 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Ralf Meier1-Dec-23 3:03
professionalRalf Meier1-Dec-23 3:03 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Iskander123451-Dec-23 5:43
Iskander123451-Dec-23 5:43 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Ralf Meier1-Dec-23 7:18
professionalRalf Meier1-Dec-23 7:18 
SuggestionRe: C# code to chart sometimes charting blank charts Pin
Richard Deeming30-Nov-23 22:56
mveRichard Deeming30-Nov-23 22:56 
Iskander12345 wrote:
C#
string query = $"SELECT * FROM Data WHERE RawDataOrder = {Convert.ToInt32(label86.Text.Trim())}";
Whilst in this specific instance you're probably safe, this sample suggests you're writing code which would be vulnerable to SQL Injection[^].

And even in this case, your code will result in query plan cache pollution - every value for the parameter will result in a different plan being compiled and stored.

Rather than trying to work out whether your values are "safe" to inject into the query, adopt a simple strategy: always use parameters.
C#
const string query = "SELECT * FROM Data WHERE RawDataOrder = @RawDataOrder";
using (SqlCommand command = new SqlCommand(query, connection))
{
    command.Parameters.AddWithValue("@RawDataOrder", Convert.ToInt32(label86.Text.Trim()));
    ...




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

AnswerRe: C# code to chart sometimes charting blank charts Pin
Richard MacCutchan30-Nov-23 23:15
mveRichard MacCutchan30-Nov-23 23:15 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Iskander123451-Dec-23 1:23
Iskander123451-Dec-23 1:23 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Richard MacCutchan1-Dec-23 3:06
mveRichard MacCutchan1-Dec-23 3:06 
AnswerRe: C# code to chart sometimes charting blank charts Pin
Dave Kreskowiak1-Dec-23 6:02
mveDave Kreskowiak1-Dec-23 6:02 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Andre Oosthuizen1-Dec-23 23:30
mveAndre Oosthuizen1-Dec-23 23:30 
AnswerRe: C# code to chart sometimes charting blank charts Pin
jschell1-Dec-23 7:35
jschell1-Dec-23 7:35 
AnswerRe: C# code to chart sometimes charting blank charts Pin
Gerry Schmitz2-Dec-23 9:02
mveGerry Schmitz2-Dec-23 9:02 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Iskander123452-Dec-23 17:02
Iskander123452-Dec-23 17:02 
Questionc# code Pin
j k Nov202329-Nov-23 18:13
j k Nov202329-Nov-23 18:13 
AnswerRe: c# code Pin
lmoelleb29-Nov-23 20:31
lmoelleb29-Nov-23 20:31 
GeneralRe: c# code Pin
j k Nov202329-Nov-23 21:04
j k Nov202329-Nov-23 21:04 
AnswerRe: c# code Pin
jschell30-Nov-23 7:05
jschell30-Nov-23 7:05 
AnswerRe: c# code Pin
Andre Oosthuizen1-Dec-23 23:35
mveAndre Oosthuizen1-Dec-23 23:35 
GeneralRe: c# code Pin
j k Nov20232-Dec-23 21:34
j k Nov20232-Dec-23 21:34 
GeneralRe: c# code Pin
Andre Oosthuizen3-Dec-23 3:35
mveAndre Oosthuizen3-Dec-23 3:35 

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.