Language: VB.NET
Pop Biz Object
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
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

