Vb.NET ExecuteReader and ExecuteNonQuery


VB.Net-Informations.com
SiteMap

ExecuteReader : ExecuteReader used for getting the query results as a DataReader object. It is readonly forward only retrieval of records and it uses select command to read through the table from the first to the last.

  Dim reader As SqlDataReader
  reader = Command.ExecuteReader()
  While reader.Read()
    MsgBox(reader.Item(0))
  End While

reader.Close()

ExecuteNonQuery : ExecuteNonQuery used for executing queries that does not return any data. It is used to execute the sql statements like update, insert, delete etc. ExecuteNonQuery executes the command and returns the number of rows affected.

  Dim retValue As Integer
  Command = New SqlCommand(Sql, Connection)

retValue = Command.ExecuteNonQuery()



  • Sponsored Program








More Source Code :
|  Home  |   VB.NET  |   C#  |   ASP.NET  |   SiteMap  |   Terms of Use  |   About  |