Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# _已用_time=Int64.Parse(dbadaset.Rows[k][1].ToString()); st.total_exposed_time=Int64.Parse(dbadaset.Rows[k][2].ToString()); st.min_exposed_time=Int64.Parse(dbadaset.Rows[k][3].ToString()); st.max_exposed_time=Int64.Parse(dbadaset.Rows[k][4].ToString()); st.average_exposed_time=Int64.Parse(dbadaset.Rows[k][5].ToString()); 列表。添加(st); } BindingSource bSource=新的BindingSource(); bSource.DataSource=列表; dataGridView1.DataSource=bSource; sda.Update(数据库数据集); conDataBase.Close(); dbataset.Dispose(); cmdDataBase.Dispose(); } 捕获(例外e5) { MessageBox.Show(e5.Message); } } 捕获(例外e4) { MessageBox.Show(e4.Message); } } 私有无效显示\图形\单击(对象发送者,事件参数e) { 尝试 { Form2 Form2=新Form2(); 表2.Show(); int i=0; form2.chart1.ChartAreas[“area”].axix.Max=list.Max(x=>x.Sl_编号); form2.chart1.ChartAreas[“area”].axix.Minimum=list.Min(x=>x.Sl_no); form2.chart1.ChartAreas[“area”].AxisX.Interval=1; form2.chart1.ChartAreas[“area”].AxisY.Max=list.Max(x=>x.average\u exposed\u time); 表格2.chart1.ChartAreas[“area”].AxisY.Minimum=0; //最小值(x=>x.平均运行时间); form2.chart1.ChartAreas[“area”].AxisY.Interval=(form2.chart1.ChartAreas[“area”].AxisY.Maximum)/10; var l=list.Select(x=>x.Sl_no); var l1=列表。选择(x=>x.平均已用时间); 而(i_C#_.net - Fatal编程技术网

C# _已用_time=Int64.Parse(dbadaset.Rows[k][1].ToString()); st.total_exposed_time=Int64.Parse(dbadaset.Rows[k][2].ToString()); st.min_exposed_time=Int64.Parse(dbadaset.Rows[k][3].ToString()); st.max_exposed_time=Int64.Parse(dbadaset.Rows[k][4].ToString()); st.average_exposed_time=Int64.Parse(dbadaset.Rows[k][5].ToString()); 列表。添加(st); } BindingSource bSource=新的BindingSource(); bSource.DataSource=列表; dataGridView1.DataSource=bSource; sda.Update(数据库数据集); conDataBase.Close(); dbataset.Dispose(); cmdDataBase.Dispose(); } 捕获(例外e5) { MessageBox.Show(e5.Message); } } 捕获(例外e4) { MessageBox.Show(e4.Message); } } 私有无效显示\图形\单击(对象发送者,事件参数e) { 尝试 { Form2 Form2=新Form2(); 表2.Show(); int i=0; form2.chart1.ChartAreas[“area”].axix.Max=list.Max(x=>x.Sl_编号); form2.chart1.ChartAreas[“area”].axix.Minimum=list.Min(x=>x.Sl_no); form2.chart1.ChartAreas[“area”].AxisX.Interval=1; form2.chart1.ChartAreas[“area”].AxisY.Max=list.Max(x=>x.average\u exposed\u time); 表格2.chart1.ChartAreas[“area”].AxisY.Minimum=0; //最小值(x=>x.平均运行时间); form2.chart1.ChartAreas[“area”].AxisY.Interval=(form2.chart1.ChartAreas[“area”].AxisY.Maximum)/10; var l=list.Select(x=>x.Sl_no); var l1=列表。选择(x=>x.平均已用时间); 而(i

C# _已用_time=Int64.Parse(dbadaset.Rows[k][1].ToString()); st.total_exposed_time=Int64.Parse(dbadaset.Rows[k][2].ToString()); st.min_exposed_time=Int64.Parse(dbadaset.Rows[k][3].ToString()); st.max_exposed_time=Int64.Parse(dbadaset.Rows[k][4].ToString()); st.average_exposed_time=Int64.Parse(dbadaset.Rows[k][5].ToString()); 列表。添加(st); } BindingSource bSource=新的BindingSource(); bSource.DataSource=列表; dataGridView1.DataSource=bSource; sda.Update(数据库数据集); conDataBase.Close(); dbataset.Dispose(); cmdDataBase.Dispose(); } 捕获(例外e5) { MessageBox.Show(e5.Message); } } 捕获(例外e4) { MessageBox.Show(e4.Message); } } 私有无效显示\图形\单击(对象发送者,事件参数e) { 尝试 { Form2 Form2=新Form2(); 表2.Show(); int i=0; form2.chart1.ChartAreas[“area”].axix.Max=list.Max(x=>x.Sl_编号); form2.chart1.ChartAreas[“area”].axix.Minimum=list.Min(x=>x.Sl_no); form2.chart1.ChartAreas[“area”].AxisX.Interval=1; form2.chart1.ChartAreas[“area”].AxisY.Max=list.Max(x=>x.average\u exposed\u time); 表格2.chart1.ChartAreas[“area”].AxisY.Minimum=0; //最小值(x=>x.平均运行时间); form2.chart1.ChartAreas[“area”].AxisY.Interval=(form2.chart1.ChartAreas[“area”].AxisY.Maximum)/10; var l=list.Select(x=>x.Sl_no); var l1=列表。选择(x=>x.平均已用时间); 而(i,c#,.net,C#,.net,此图显示对象ID包含重复项。在我更改代码(标记为粗体)之前,它们不存在。帮我解决这个问题 这不是问题:sys.dm_exec_procedure_stats很可能有重复项,因为它显示各种缓存的查询计划。无论您的问题是什么,都不是这个。请编辑您的问题并包含格式正确的代码。只需插入您使用的编辑器中的代码,然后选择它并单击{}按钮。您最好先仔细阅读中的所有内容,然后重试。。。 using System; using System.Collections.Generic; using System.Co

此图显示对象ID包含重复项。在我更改代码(标记为粗体)之前,它们不存在。帮我解决这个问题


这不是问题:sys.dm_exec_procedure_stats很可能有重复项,因为它显示各种缓存的查询计划。无论您的问题是什么,都不是这个。

请编辑您的问题并包含格式正确的代码。只需插入您使用的编辑器中的代码,然后选择它并单击
{}
按钮。您最好先仔细阅读中的所有内容,然后重试。。。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            comboBox1.Items.Add("bora\\bora");
        }

       private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void connect_Click(object sender, EventArgs e)
        {
            try
            {
                comboBox2.Items.Clear();
                comboBox3.Items.Clear();
                dataGridView1.Rows.Clear();
                string sname = comboBox1.SelectedItem.ToString();
                string conString = @"server=" + sname + ";  Integrated Security=True";
                if (sname == "")
                {
                   MessageBox.Show("Please enter a Server name");
                }
                else
                {
                    using (SqlConnection con = new SqlConnection(conString))
                    {
                        con.Open();
                        MessageBox.Show("Connected");
                        using (SqlCommand cmd = new SqlCommand("SELECT name from sys.databases order by name asc", con))
                        {
                            using (IDataReader dr = cmd.ExecuteReader())
                            {
                                while (dr.Read())
                                {
                                    comboBox2.Items.Add(dr[0].ToString());
                                }
                            }
                        }
                    }
                    MessageBox.Show("Populated");
                }
                Console.WriteLine("Hello1223");
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.ToString());
            }
        }

        private void display_procs_Click(object sender, EventArgs e)
        {
            try
            {
                comboBox3.Items.Clear();
                dataGridView1.Rows.Clear();
                string sname = comboBox1.SelectedItem.ToString();
                string dname = comboBox2.SelectedItem.ToString();
                string conString = @"server=" + sname + ";  Integrated Security=True";

                using (SqlConnection con = new SqlConnection(conString))
                {
                    con.Open();
                    using (SqlCommand cmd = new SqlCommand("SELECT name from " + dname + ".sys.procedures order by name asc", con))
                    {
                        using (IDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                comboBox3.Items.Add(dr[0].ToString());
                            }
                        }
                    }
                }
                MessageBox.Show("Populated");
                Console.WriteLine("Hello");
            }
            catch (Exception e3)
            {
                MessageBox.Show(e3.ToString());
            }
        }
        **public void execution()
        {
            string sname = comboBox1.Text.Trim();
            string dname = comboBox2.SelectedItem.ToString();
            string pname = comboBox3.SelectedItem.ToString();
            string conString = @"server=" + sname + ";  Integrated Security=True; MultipleActiveResultSets=True;";
            SqlCommand s = new SqlCommand("exec " + dname + ".dbo." + pname + ";");
            SqlConnection conDataBase = new SqlConnection(conString);
            conDataBase.Open();
            s.Connection = conDataBase;
            s.CommandTimeout = 0;
            int i = 0;
            List<Action> a = new List<Action>();
            int j = Int32.Parse(exec.Text.ToString());
            for (i = 0; i < j; i++)
            {
                a.Add(new Action(() => s.ExecuteNonQueryAsync()));
            }
            Parallel.ForEach<Action>(a, (o => o()));
        }**

        List<Stats> list = new List<Stats>();
        private void get_stats_Click(object sender, EventArgs e)
        {
            try
            {
                list.Clear();
                //exec.Clear();
                string sname = comboBox1.Text.Trim();
                string dname = comboBox2.SelectedItem.ToString();
                string pname = comboBox3.SelectedItem.ToString();
                string conString = @"server=" + sname + ";  Integrated Security=True;";
                SqlConnection conDataBase = new SqlConnection(conString);
                conDataBase.Open();
                execution();
                SqlCommand cmdDataBase = new SqlCommand("SELECT ROW_NUMBER() OVER (ORDER BY sql_handle) AS Sl_no,last_elapsed_time, total_elapsed_time, min_elapsed_time, max_elapsed_time, total_elapsed_time/execution_count as average_elapsed_time FROM sys.dm_exec_query_stats WHERE sql_handle in (SELECT sql_handle FROM sys.dm_exec_procedure_stats WHERE object_id IN (SELECT object_id FROM " + dname + ".sys.procedures WHERE name='" + pname + "'));", conDataBase);
                try
                {
                    SqlDataAdapter sda = new SqlDataAdapter();
                    sda.SelectCommand = cmdDataBase;
                    DataTable dbadataset = new DataTable();
                    dbadataset.Dispose(); 
                    sda.Fill(dbadataset);

                    for (int k = 0; k < dbadataset.Rows.Count; k++)
                    {
                        Stats st = new Stats();
                        st.Sl_no = Int64.Parse(dbadataset.Rows[k][0].ToString());
                    st.last_elapsed_time = Int64.Parse(dbadataset.Rows[k][1].ToString());
                    st.total_elapsed_time = Int64.Parse(dbadataset.Rows[k][2].ToString());
                    st.min_elapsed_time = Int64.Parse(dbadataset.Rows[k][3].ToString());
                     st.max_elapsed_time = Int64.Parse(dbadataset.Rows[k][4].ToString());
                   st.average_elapsed_time = Int64.Parse(dbadataset.Rows[k][5].ToString());
                        list.Add(st);
                    }
                    BindingSource bSource = new BindingSource();
                    bSource.DataSource = list;
                    dataGridView1.DataSource = bSource;
                    sda.Update(dbadataset);
                    conDataBase.Close();
                    dbadataset.Dispose();
                    cmdDataBase.Dispose();
                }
                catch (Exception e5)
                {
                    MessageBox.Show(e5.Message);
                }
            }
            catch (Exception e4)
            {
                MessageBox.Show(e4.Message);
            }
        }
        private void display_graph_Click(object sender, EventArgs e)
        {
            try
            {
                Form2 form2 = new Form2();
                form2.Show();
                int i = 0;
                form2.chart1.ChartAreas["area"].AxisX.Maximum = list.Max(x => x.Sl_no);
                form2.chart1.ChartAreas["area"].AxisX.Minimum = list.Min(x => x.Sl_no);
                form2.chart1.ChartAreas["area"].AxisX.Interval = 1;

     form2.chart1.ChartAreas["area"].AxisY.Maximum = list.Max(x => x.average_elapsed_time);
                form2.chart1.ChartAreas["area"].AxisY.Minimum = 0;
                    //list.Min(x => x.average_elapsed_time);
                form2.chart1.ChartAreas["area"].AxisY.Interval = (form2.chart1.ChartAreas["area"].AxisY.Maximum) / 10;

                var l = list.Select(x => x.Sl_no);
                var l1 = list.Select(x => x.average_elapsed_time);
                while (i < list.Count)
                {
                    form2.chart1.Series["Query"].Points.AddXY(l.ElementAt(i), l1.ElementAt(i));
                    i++;
                }
            }
            catch (Exception e7)
            {
                MessageBox.Show(e7.Message);
            }
        }
        private void groupBox5_Enter(object sender, EventArgs e)
        {}
        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {}
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {}
        private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
        }
        private void groupBox6_Enter(object sender, EventArgs e)
        {
        }
    }
}