Click here to Skip to main content
15,890,882 members
Home / Discussions / C#
   

C#

 
GeneralRe: service top pulling when list is emty c# Pin
Sascha Lefèvre16-Apr-15 4:54
professionalSascha Lefèvre16-Apr-15 4:54 
GeneralRe: service top pulling when list is emty c# Pin
Richard MacCutchan16-Apr-15 4:33
mveRichard MacCutchan16-Apr-15 4:33 
GeneralRe: service top pulling when list is emty c# Pin
Dave Kreskowiak16-Apr-15 4:25
mveDave Kreskowiak16-Apr-15 4:25 
Questionrdlc background image doesn't fit page Pin
medo0-15-Apr-15 22:56
medo0-15-Apr-15 22:56 
QuestionDownloading a PDF File from a URL Pin
Vimalsoft(Pty) Ltd15-Apr-15 22:39
professionalVimalsoft(Pty) Ltd15-Apr-15 22:39 
AnswerRe: Downloading a PDF File from a URL Pin
OriginalGriff15-Apr-15 22:55
mveOriginalGriff15-Apr-15 22:55 
QuestionRtb set start line when load form Pin
DPaul199415-Apr-15 7:26
DPaul199415-Apr-15 7:26 
AnswerRe: Rtb set start line when load form Pin
Richard Deeming15-Apr-15 8:03
mveRichard Deeming15-Apr-15 8:03 
Your code is vulnerable to SQL Injection[^].

NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.
C#
// Since you're only reading a single record, you should only select a single record.
// Also, avoid "SELECT *"; explicitly specify the columns you need.
const string citireLastChapter = "SELECT articol_ramas, data FROM cursuri WHERE capitol = @capitol LIMIT 1";

// Wrap disposable objects in a "using" block:
using (SQLiteCommand cmd = new SQLiteCommand(citireLastChapter, Conexiune.getConnection()))
{
    cmd.CommandType = CommandType.Text;
    cmd.Parameters.AddWithValue("@capitol", SimulatorManager.CursuriCapitol);

    // Wrap disposable objects in a "using" block:
    using (SQLiteDataReader read = cmd.ExecuteReader())
    {
        // No need for a loop to read a single record:
        if (read.Read())
        {
            SimulatorManager.ArticolRamasCursuri = (int)read["articol_ramas"];
            data = read["data"].ToString();
        }
    }
}

// No need for ".ToString()" on a string:
richTextBox1.Text = data;

int row = SimulatorManager.ArticolRamasCursuri;
if (row >= 0 && richTextBox1.Lines.Length > row)
{
    int startLineIndex = richTextBox1.GetFirstCharIndexFromLine(row);
    int lineLength = richTextBox1.Lines[row].Length;

    int col = 33;
    if (lineLength > col)
    {
        startLineIndex += col;
        lineLength -= col;
    }

    richTextBox1.Select(startLineIndex, lineLength);
    richTextBox1.ScrollToCaret();
}



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



modified 15-Apr-15 14:15pm.

GeneralRe: Rtb set start line when load form Pin
DPaul199415-Apr-15 8:11
DPaul199415-Apr-15 8:11 
GeneralRe: Rtb set start line when load form Pin
Richard Deeming15-Apr-15 8:16
mveRichard Deeming15-Apr-15 8:16 
GeneralRe: Rtb set start line when load form Pin
DPaul199415-Apr-15 8:17
DPaul199415-Apr-15 8:17 
Questioni have one question related web api integrate in my project Pin
Manoj Gupta 00714-Apr-15 21:54
Manoj Gupta 00714-Apr-15 21:54 
AnswerRe: i have one question related web api integrate in my project Pin
Pete O'Hanlon14-Apr-15 22:39
mvePete O'Hanlon14-Apr-15 22:39 
QuestionWhat is the difference between Object Oriented,Object based and purely Object Oriented in terms of any language ? Pin
Gyana_Ranjan Dash14-Apr-15 20:12
Gyana_Ranjan Dash14-Apr-15 20:12 
AnswerRe: What is the difference between Object Oriented,Object based and purely Object Oriented in terms of any language ? Pin
OriginalGriff14-Apr-15 21:36
mveOriginalGriff14-Apr-15 21:36 
GeneralRe: What is the difference between Object Oriented,Object based and purely Object Oriented in terms of any language ? Pin
Gyana_Ranjan Dash14-Apr-15 22:19
Gyana_Ranjan Dash14-Apr-15 22:19 
GeneralRe: What is the difference between Object Oriented,Object based and purely Object Oriented in terms of any language ? Pin
OriginalGriff14-Apr-15 22:45
mveOriginalGriff14-Apr-15 22:45 
AnswerRe: What is the difference between Object Oriented,Object based and purely Object Oriented in terms of any language ? Pin
Florian Braun14-Apr-15 21:40
professionalFlorian Braun14-Apr-15 21:40 
Questionbest coding practises in c# Pin
dhivya.sakthi14-Apr-15 19:14
dhivya.sakthi14-Apr-15 19:14 
AnswerRe: best coding practises in c# Pin
Gyana_Ranjan Dash14-Apr-15 19:38
Gyana_Ranjan Dash14-Apr-15 19:38 
AnswerRe: best coding practises in c# Pin
V.14-Apr-15 20:15
professionalV.14-Apr-15 20:15 
AnswerRe: best coding practises in c# Pin
aadhira14-Apr-15 20:22
aadhira14-Apr-15 20:22 
GeneralRe: best coding practises in c### Pin
dhivya.sakthi14-Apr-15 20:40
dhivya.sakthi14-Apr-15 20:40 
SuggestionRe: best coding practises in c# Pin
aadhira14-Apr-15 21:09
aadhira14-Apr-15 21:09 
GeneralMessage Removed Pin
14-Apr-15 19:11
dhivya.sakthi14-Apr-15 19:11 

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.