Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# multi agent framework based on MS Orleans Pin
Gerry Schmitz9-Dec-23 6:37
mveGerry Schmitz9-Dec-23 6:37 
GeneralRe: C# multi agent framework based on MS Orleans Pin
Jerome Fortias 20229-Dec-23 7:59
Jerome Fortias 20229-Dec-23 7:59 
QuestionMessenger design with C# Pin
parya mardani8-Dec-23 12:05
parya mardani8-Dec-23 12:05 
AnswerRe: Messenger design with C# Pin
Dave Kreskowiak8-Dec-23 14:28
mveDave Kreskowiak8-Dec-23 14:28 
AnswerRe: Messenger design with C# Pin
Gerry Schmitz9-Dec-23 6:35
mveGerry Schmitz9-Dec-23 6:35 
Questionis there any way to get bordercolor same as candle color using ternary in the code below Pin
j k Nov20236-Dec-23 5:48
j k Nov20236-Dec-23 5:48 
AnswerRe: is there any way to get bordercolor same as candle color using ternary in the code below Pin
Gerry Schmitz9-Dec-23 6:32
mveGerry Schmitz9-Dec-23 6:32 
QuestionC# code to chart sometimes charting blank charts Pin
Iskander1234530-Nov-23 16:01
Iskander1234530-Nov-23 16:01 
I have the below function which is called with a button click. It is supposed to chart from a database. The problem is that when selecting from database I am filtering the database using "WHERE". When I don't use this "WHERE" and plot the whole database table, the code works fine, but when I use this filter, it often leads to blank charts even though the data is there in the table. What is wrong with this code?



void PlotChart()
        {
            try
            {
                // Clear existing series
                chart1.Series.Clear();

                // Create new series
                Series First = new Series("Series11");
                Series Second = new Series("Series12");

                // Set chart type
                First.ChartType = SeriesChartType.Spline;
                Second.ChartType = SeriesChartType.Spline;

                // Set custom colors for each series
                First.Color = Color.Blue; // Set the color for First series
                Second.Color = Color.Orange; // Set the color for Second series


                // Connect to the database and retrieve data
                using (SqlConnection connection = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True"))
                {
                    if(connection.State == ConnectionState.Closed)
                    {
                        connection.Open();
                    }
                    

                    // Select only rows where RawDataOrder is equal to label86 text
                    string query = $"SELECT * FROM Data WHERE RawDataOrder = {Convert.ToInt32(label86.Text.Trim())}";
                    using (SqlCommand command = new SqlCommand(query, connection))
                    {
                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                // Assuming the first column is 'ID', the second is '11', and the third is '12'
                                int id = reader.GetInt32(0);
                                int value11 = reader.GetInt32(1);
                                int value12 = reader.GetInt32(8);

                                // Add data points to the series
                                First.Points.AddXY(id, value11);
                                Second.Points.AddXY(id, value12);
                            }
                        }
                    }
                }

                // Add the series to the chart
                chart1.Series.Add(First);
                chart1.Series.Add(Second);

                // Set chart title
                chart1.Titles.Clear();
                chart1.Titles.Add(new Title("Channel 1"));

                // Refresh the chart to update the display
                chart1.Update();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error PlotChart", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

AnswerRe: C# code to chart sometimes charting blank charts Pin
Ralf Meier30-Nov-23 21:12
mveRalf Meier30-Nov-23 21:12 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Iskander123451-Dec-23 0:52
Iskander123451-Dec-23 0:52 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Ralf Meier1-Dec-23 2:03
mveRalf Meier1-Dec-23 2:03 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Iskander123451-Dec-23 4:43
Iskander123451-Dec-23 4:43 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Ralf Meier1-Dec-23 6:18
mveRalf Meier1-Dec-23 6:18 
SuggestionRe: C# code to chart sometimes charting blank charts Pin
Richard Deeming30-Nov-23 21:56
mveRichard Deeming30-Nov-23 21:56 
AnswerRe: C# code to chart sometimes charting blank charts Pin
Richard MacCutchan30-Nov-23 22:15
mveRichard MacCutchan30-Nov-23 22:15 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Iskander123451-Dec-23 0:23
Iskander123451-Dec-23 0:23 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Richard MacCutchan1-Dec-23 2:06
mveRichard MacCutchan1-Dec-23 2:06 
AnswerRe: C# code to chart sometimes charting blank charts Pin
Dave Kreskowiak1-Dec-23 5:02
mveDave Kreskowiak1-Dec-23 5:02 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Andre Oosthuizen1-Dec-23 22:30
mveAndre Oosthuizen1-Dec-23 22:30 
AnswerRe: C# code to chart sometimes charting blank charts Pin
jschell1-Dec-23 6:35
jschell1-Dec-23 6:35 
AnswerRe: C# code to chart sometimes charting blank charts Pin
Gerry Schmitz2-Dec-23 8:02
mveGerry Schmitz2-Dec-23 8:02 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Iskander123452-Dec-23 16:02
Iskander123452-Dec-23 16:02 
Questionc# code Pin
j k Nov202329-Nov-23 17:13
j k Nov202329-Nov-23 17:13 
AnswerRe: c# code Pin
lmoelleb29-Nov-23 19:31
lmoelleb29-Nov-23 19:31 
GeneralRe: c# code Pin
j k Nov202329-Nov-23 20:04
j k Nov202329-Nov-23 20:04 

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.