Click here to Skip to main content
15,849,996 members
Home / Discussions / C#
   

C#

 
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 
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 
The way you've written your SQL code, specifically the parameter you put in the query string, makes it impossible to debug. It's not the existence of the WHERE clause that's the problem. It's that your WHERE clause condition doesn't match any records.

To be able to debug this, you have to rewrite the code so you can see what's going on with the debugger:
C#
string query = "SELECT * FROM Data WHERE RawDataOrder = @orderId";

// Parse the UI value. Why you're using a label to "store" data
// used in your busniess rules is beyond my comprehension.
int orderId;

if (int.TryParse(label86.Text.Trim(), out orderId))
{
    // The parse worked! If execution gets to the next statement, orderId
    // has a valid value. Since the value is sitting in a variable, you
    // can now debug the code to see its value and what is being passed
    // to the SQL query.

    // Build the SQL Command
    using (SqlConnection conn = new SqlConnection("... connection string ..."))
    {

        using (SqlCommand comm = new SqlCommand(query, conn))
        {
            SqlParameter orderIdParam = new SqlParameter("@orderId", SqlDbType.Int);
            orderIdParam.Value = orderId;
            comm.Parameters.Add(orderIdParam);

            // You forgot to open the connection
            conn.Open();
            using (SqlDataReader reader = comm.ExecuteReader())
            {
                while (reader.Read())
                {
                    ...
                }
            }
        }
    }
}
else
{
    // The parse failed! You might want to tell the user about that.
    // If execution gets to here, the parse failed and you do not have a valid
    // orderId value.
}


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 
QuestionConverting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Codice Fictor26-Nov-23 13:19
Codice Fictor26-Nov-23 13:19 
AnswerRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Dave Kreskowiak26-Nov-23 15:07
mveDave Kreskowiak26-Nov-23 15:07 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Codice Fictor26-Nov-23 16:52
Codice Fictor26-Nov-23 16:52 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Richard MacCutchan26-Nov-23 22:28
mveRichard MacCutchan26-Nov-23 22:28 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Gerry Schmitz26-Nov-23 22:45
mveGerry Schmitz26-Nov-23 22:45 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Codice Fictor27-Nov-23 5:08
Codice Fictor27-Nov-23 5:08 

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.