[英]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.