-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathsample6.vb
More file actions
45 lines (45 loc) · 1.87 KB
/
sample6.vb
File metadata and controls
45 lines (45 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Imports NorthwindWithSprocsTableAdapters
<System.ComponentModel.DataObject()> _
Public Class SuppliersBLLWithSprocs
Private _suppliersAdapter As SuppliersTableAdapter = Nothing
Protected ReadOnly Property Adapter() As SuppliersTableAdapter
Get
If _suppliersAdapter Is Nothing Then
_suppliersAdapter = New SuppliersTableAdapter()
End If
Return _suppliersAdapter
End Get
End Property
<System.ComponentModel.DataObjectMethodAttribute _
(System.ComponentModel.DataObjectMethodType.Select, True)> _
Public Function GetSuppliers() As NorthwindWithSprocs.SuppliersDataTable
Return Adapter.GetSuppliers()
End Function
<System.ComponentModel.DataObjectMethodAttribute _
(System.ComponentModel.DataObjectMethodType.Update, True)> _
Public Function UpdateSupplier(companyName As String, contactName As String, _
contactTitle As String, supplierID As Integer) As Boolean
Dim suppliers As NorthwindWithSprocs.SuppliersDataTable = _
Adapter.GetSupplierBySupplierID(supplierID)
If suppliers.Count = 0 Then
' no matching record found, return false
Return False
End If
Dim supplier As NorthwindWithSprocs.SuppliersRow = suppliers(0)
supplier.CompanyName = companyName
If contactName Is Nothing Then
supplier.SetContactNameNull()
Else
supplier.ContactName = contactName
End If
If contactTitle Is Nothing Then
supplier.SetContactTitleNull()
Else
supplier.ContactTitle = contactTitle
End If
' Update the product record
Dim rowsAffected As Integer = Adapter.Update(supplier)
' Return true if precisely one row was updated, otherwise false
Return rowsAffected = 1
End Function
End Class