c# - Trying to query within query but it doesn't work -
i trying populate table data sql , have query in query in order expected results.
here how trying do:
// queries var transakcionet = db.query("select * ditari idurdheresa = @0", id); // idklientit has unique value below query return 1 row var klienti = "select cemertimi_i_klientit klienti (idklientit = @0)"; <tbody> @foreach(var transakcioni in transakcionet){ <tr> // works @foreach(var kontoja in db.query(kontotrans, transakcioni.idkontos)){ <td>@kontoja.cnumri_i_kontos</td> } // causing error (i guess) @foreach(var klja in db.query(klienti, transakcioni.idklientit)){ <td>@klja.cemertimi_i_klientit</td> } </tr> </tbody>
i dont know missing but.
here error message:
no value given 1 or more required parameters.
description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code.
exception details: system.data.oledb.oledbexception: no value given 1 or more required parameters.
@webber2k6 right. there null given query
.
first, ensure not crash (you may need @using system.linq
on top of file):
@foreach(var transakcioni in transakcionet.where(t => t.idkontos != null && t.idklientit != null){ <tr> // works @foreach(var kontoja in db.query(kontotrans, transakcioni.idkontos)){ <td>@kontoja.cnumri_i_kontos</td> } // causing error (i guess) @foreach(var klja in db.query(klienti, transakcioni.idklientit)){ <td>@klja.cemertimi_i_klientit</td> } </tr>
but not explain why value null
in first place. obviously, makes sense if id*
properties nullable, which, guess, case regarding error message get.
Comments
Post a Comment