我正在使用 Microsoft Access 数据库。当我尝试执行代码时,它得到“行/列不存在数据”。我在 Microsoft Access 中执行了 sql 代码,它工作正常。
OleDbCommand cmd1 = new OleDbCommand("SELECT SUM (adet) AS gToplam from stok_isl WHERE stok_id = @veri and tur = 'GİRİŞ'", conn);
cmd1.Parameters.AddWithValue("@veri", combo);
OleDbDataReader dr1 = cmd1.ExecuteReader();
OleDbCommand cmd2 = new OleDbCommand("SELECT SUM (adet) AS cToplam from stok_isl WHERE stok_id = @veri and tur = 'ÇIKIŞ'", conn);
cmd2.Parameters.AddWithValue("@veri", combo);
OleDbDataReader dr2 = cmd2.ExecuteReader();
Sonuc = Convert.ToDouble(dr1["gToplam"]) - Convert.ToDouble(dr2["cToplam"]);
MessageBox.Show(Sonuc.ToString());