简体   繁体   English

应用程序中返回的记录数与数据库中不同

[英]The number of records returned is different in the application than in the database

I am making corrections to an application that previously worked flawlessly and returned records perfectly.我正在对以前完美运行并完美返回记录的应用程序进行更正。 There was no problem.没有问题。 I have such a problem.我有这样的问题。 It happens, for example, that I have 3 records with the status N and it returns 2. And so on.例如,我有 3 条状态为 N 的记录,它返回 2。依此类推。 it just doesn't often return the same number of records to me as I have in the database.它只是不会经常向我返回与数据库中相同数量的记录。 In the meantime, I often work on an application that works in production.与此同时,我经常开发一个可以在生产环境中运行的应用程序。 And I noticed the dependence that, for example, an order such as 724xxx, which I do not see on my test application, is an order that I entered a moment earlier in production to see "what's inside" because unfortunately you have to work.而且我注意到了这样的依赖性,例如,我在测试应用程序中看不到的 724xxx 之类的订单是我在生产中早些时候输入的订单,以查看“里面有什么”,因为不幸的是你必须工作。

After entering the application, a given method is launched and it is responsible for connecting with orders.进入应用程序后,启动一个给定的方法,它负责连接订单。

public void Read_Main()
        {         
            
            try
            {
                using (OracleConnection conn = new OracleConnection(Connection.oradb))
                using (OracleCommand cmd = new OracleCommand("SELECT VBELN as ZLECENIE,KUNNR as ODBIORCA,DATA_ZLEC as DATA,UZEIT_ZLEC as GODZINA,MAIL_UTWORZYL as UTWORZYŁ,MAIL_PH as PH, STATUS as ST,WARTOSC_N AS WARTOSC FROM DWS1.AUTOMAT_NGL_POZ", conn))
                {
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                        using (OracleDataReader reader = cmd.ExecuteReader())
                        {

                            reader.Read();

                            DataTable dataTable = new DataTable();
                            dataTable.Load(reader);



                            List<DataRow> newOrders = dataTable.AsEnumerable().Where(x => x.Field<string>("ST") == "N").ToList();


                            foreach (var item in newOrders)
                            {
                                Automation_Positive_Cena_2(conn, item["ZLECENIE"].ToString(), item["ODBIORCA"].ToString(), item["UTWORZYŁ"].ToString(), item["PH"].ToString());
                            }



                            dataGridView1.DataSource = dataTable;
                            dataGridView1.RowHeadersVisible = false;
                            dataGridView2.Hide();
                            label3.Show();
                            dataGridView2.DataSource = "";
                            negativetbox.Clear();



                        }
                        conn.Close();
                    }
                   
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

Isn't that reader.read() discarding the first row of your data.那不是reader.read()丢弃数据的第一行。 Then you populate the DataTable ?然后你填充DataTable Is that why you're getting one row less?这就是你少一排的原因吗?

So try deleting that line and just filling the DataTable .因此,请尝试删除该行并仅填充DataTable

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何汇总数据库中给定日期的多个时间记录。 错误:子查询返回的值超过1 - How to sum up multiple time records on a given date in database. Error:Subquery returned more than 1 value 如果返回的记录数低于 5000,这会失败吗? - Will this fail if the returned number of records is below 5000? 将大量记录插入数据库 - Inserting massive number of records into database HttpClient-返回的内容与浏览器不同 - HttpClient - Different content returned than browser 根据数据库中的记录数显示许多usercontrol - Display a number of usercontrol based on the number of records in the database UserManager返回的ID与数据库中的ID不同 - Id returned by UserManager is different from Id in Database SQL Server 2008 EF 4-限制使用权限返回的数据库记录? - SQL Server 2008 EF 4 - limiting database records returned using permissions? 在gridview中每页显示不同数量的记录 - Display different number of records at each page in gridview C# CsvHelper - 具有不同数量属性的记录 - C# CsvHelper - Records with different number of properties 使用sql从数据库获取记录数 - Get the number of records from a database using sql
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM