Code: Select all
TrinoConnectionProperties properties = new TrinoConnectionProperties()
`{ Host = "127.0.0.1", Port = 7777, Catalog = "delta", User = "admin",
Schema = "runtime",
EnableSsl = false
};
using (TrinoConnection connection = new TrinoConnection(properties))
{
connection.Open();
using (IDbCommand command69 = new TrinoCommand(connection, query1100))
using (IDataReader reader = command69.ExecuteReader())`
{
reader.Read();
int a = reader.FieldCount;
System.Data.DataTable dataTable1 = new System.Data.DataTable();
dataTable1.Load(reader);
string aaa = dataTable1.Rows[0][0].ToString();
string bb= dataTable1.Rows[0][1].ToString();
}
}
DataTable1.Load(reader);
Der Fehler:
Ausnahme: 'Spalte' Spalte 'Argument' Argument 'Argument' Argument 'Argument' Argument 'nicht null. (Parameter 'Spalte')
Können Sie mir bitte helfen zu verstehen, warum ich den Fehler bekomme?
Code: Select all
string aaa = dataTable1.Rows[0][0].ToString();
string bb= dataTable1.Rows[0][1].ToString();
< /code>
query1100: < /p>
" select operatorlongid,sum(UNITSQUANTITY) SUM_UNITSQUANTITY ,sum(UNITSQUANTITY)/100.00 Valor_cobrado,count(distinct transactionid) Total_val from ( " +
" select * from ( " +
" select " +
" transactiondate," +
" case when linelongid = '1998' and transactiondate >= '2024-09-02'||'T04:00:00' and operatorlongid = '41' then '4' " +
" else operatorlongid " +
" end as operatorlongid, " +
" productlongid, " +
" UNITSQUANTITY, " +
" transactionid " +
" from " +
" delta.tmlraw.t_stg_validations " +
" where " +
" rawloaddateiso >= '20230701' " +
" and transactiondate >= '2024-08-26'||'T04:00:00' " +
" and transactiondate < '2024-09-26'||'T03:59:59' " +
" and validationStatus in (0,4,5,6)" +
" and productlongid = 'id-prod-zapping' " +
" ) " +
" where operatorlongid in ('41','42','43','44') " +
" group by " +
" transactiondate, " +
" operatorlongid, " +
" productlongid, " +
" UNITSQUANTITY, " +
" transactionid " +
" ) " +
" group by operatorlongid " +
" order by operatorlongid asc ";
< /code>
Andernfalls erhalte ich einen Code, der funktioniert. Aber wer kann ich Daten aus einer bestimmten Spalte und einer bestimmten Zeile erhalten, z. using (IDbCommand command69 = new TrinoCommand(connection, query1000))
{
connection.Open();
using (IDataReader reader = command69.ExecuteReader())
{
while (reader.Read())
{
for (int i = 0; i < reader.FieldCount; i++)
{
Console.WriteLine($"{reader.GetName(i)} -> {reader.GetDataTypeName(i)} : {reader.GetValue(i)}");
string aaaaa= reader.GetString(i);
string bbbb = reader.GetDataTypeName(i);
}
}
float a = reader.GetInt32(1);
int b = reader.GetInt32(5);
int c = reader.GetInt32(8);
}
}