.NET How to get Sql response to string? -


after inserting db server's response. example "x rows effected" or other messages, , put them string variable. how implement in code? c# or vb - doesn't matter me. couldn't find specific on this, n00b @ programming. thank kindly.could kindly provide example me? here code:

    private function insertscr(byval byte2insert byte()) boolean      dim _con sqlconnection     dim querystmt string     dim _cmd sqlcommand     dim param sqlparameter      try          _con = new sqlconnection(my.settings.dbconnstr)         querystmt = "update errorlog set screen =  @content where(errorlogid = 2)"         _cmd = new sqlcommand(querystmt, _con)         param = _cmd.parameters.add("@content", sqldbtype.varbinary)          param.value = byte2insert          _con.open()         _cmd.executenonquery()         _con.close()          return true      catch ex exception          return false      end try  end function   

assuming sql server, sqlconnection object has infomessage event raised each of these sorts of messages (it has mode can enabled error messages delivered via same event, see fireinfomessageeventonusererrors)

you access text of these messages extracting message property second argument passed event handler.


something like:

    ...     _con = new sqlconnection(my.settings.dbconnstr)     addhandler _con.infomessage,sub(sender,e)                                     messagebox.show(e.message)                                 end sub     querystmt = "update errorlog set screen =  @content where(errorlogid = 2)"     ... 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -