sqldataadapter - SqlAdapter.Fill(DataSet) fills only first datatable returned by stored procedure in Xamarin -
i try fill dataset multiple tables using stored procedure on sqlserver. code simple:
var execprocedurestring = "exec dbo.someprocedure ..." var mydataset = new dataset(); using (var conn = new sqlconnection(connectionstring)) { using (var command = new sqlcommand(execprocedurestring, conn)) { using (var adapter = new sqldataadapter(command)) { adapter.fill(mydataset); } } }
but somehow fill creates (and fills) first table (not others). not procedure because returns normal data. missing in adapter?
i still don't know why fill not working. worked before. there's walkaround (without need specificate datatables) envolves sqldatareader
var execprocedurestring = "exec dbo.someprocedure ..." var mydataset = new dataset(); using (var conn = new sqlconnection(connectionstring)) { using (var command = new sqlcommand(execprocedurestring, conn)) { conn.open(); using (var reader = new command.executereader()) { while(!reader.isclosed) //table.load closes reader if contains no more rows { var table = new datatable(); mydataset.tables.add(table); table.load(reader) } } } }
Comments
Post a Comment