sql server - Error - There is no row at position 0 C# -
when debug project, error:
there no row @ position 0
code error in return (byte[]) ...
public static byte[] baixararquivo(long codarquivo) { database db = databasefactory.createdatabase(); dbcommandwrapper dbcommandwrapper = db.getstoredproccommandwrapper("gerrel_arquivo_baixar"); dbcommandwrapper.addinparameter("@codarquivo" , dbtype.int32 , codarquivo); >>>> return (byte[]) db.executedataset(dbcommandwrapper).tables[0].rows[0]["arquivo"]; }
i checked database , found no problems. might happening?
=====
private void page_load (object sender, system.eventargs e) { string codigoarquivo = request.querystring ["codarquivo"]; response.binarywrite (bo.arquivo.baixararquivo (int.parse (codigoarquivo))); }
executedataset
seems return dataset
contains table empty. have check if it's correct no rows returned stored-procedure.
if it's possible check rows.count
:
var ds = db.executedataset(dbcommandwrapper); if(ds.tables[0].rows.count == 0) return null; else return (byte[]) ds.tables[0].rows[0]["arquivo"];
otherwise have fix sql in sp.
Comments
Post a Comment