sql server - ExecuteScalar and SqlDataAdapter.Fill Behave different for same query -



sql server - ExecuteScalar and SqlDataAdapter.Fill Behave different for same query -

i have big stored procedure run. @ end supposed select singe value if succeeded or not, run query

dim command new sqlcommand(sqlstring, conn) homecoming command.executescalar()

which works. there error in stored procedure. know causing error because logic in stored procedure rolls transactions, , after execute scalar call, transaction count downwards 0 , info hasn't changed. no sql exception generated.

the unusual part is, changed code grab result sets sp see if more information. called same sp this,

dim daobj sqldataadapter = new sqldataadapter dim commandobj sqlcommand = new sqlcommand(sqlstring, conn) daobj.selectcommand = commandobj dim ds new dataset() daobj.fill(ds)

when run this, exact same sql before, executing exact same stored procedure, time sql exception because 1 of nested sp calls missing required parameters.

so cause this? why running 1 way produce error , other way have error not study it? difference on purpose, or kind of obscure bug in ado.net?

a dataadaptor consumes datasets come client. exception dataset too.

executescalar consumes 1st row, 1st column, 1st dataset only.

don't utilize executescalar keep consuming datareaders until no more back use dataadaptor.fill (dataset). skip exceptions filling datatables too

sql-server vb.net ado.net

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -