CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: VB.NET

Pop Biz Object

124 Views
Copy Code Show/Hide Line Numbers
   1:  Imports System.Data.SqlClient
   2:   
   3:  Public Class VendorDB
   4:   
   5:      Public Shared Function GetVendors() As List(Of Vendor)
   6:          Dim vendorList As New List(Of Vendor)
   7:          Dim connection As SqlConnection = PayablesDB.GetConnection
   8:          Dim selectStatement As String _
   9:              = "SELECT * FROM Vendors "
  10:          Dim selectCommand As New SqlCommand(selectStatement, connection)
  11:          Try
  12:              connection.Open()
  13:              Dim reader As SqlDataReader = selectCommand.ExecuteReader()
  14:              Dim vendor As Vendor
  15:              Do While reader.Read
  16:                  vendor = New Vendor
  17:                  vendor.VendorID = CInt(reader("VendorID"))
  18:                  vendor.Name = reader("Name").ToString
  19:                  vendor.Address1 = reader("Address1").ToString
  20:                  vendor.Address2 = reader("Address2").ToString
  21:                  vendor.City = reader("City").ToString
  22:                  vendor.State = reader("State").ToString
  23:                  vendor.ZipCode = reader("ZipCode").ToString
  24:                  vendorList.Add(vendor)
  25:              Loop
  26:              reader.Close()
  27:          Catch ex As SqlException
  28:              Throw ex
  29:          Finally
  30:              connection.Close()
  31:          End Try
  32:          Return vendorList
  33:      End Function
  34:   
  35:  End Class
by mbbrennan
  January 02, 2010 @ 3:04pm

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate