Hi Walter and thanks for your reply. I used the code you posted as a
template for the partial class but I'm not getting any data to update even
though the correct values are getting set in a DataTable and being passed
into my UpdateBatchCnty AssetsAssetMana gement function shown below. I'm also
posting the code for the partial class. The Update method being called in my
Business class was generated by the designer.
I'm posting my business logic layer class here:
Imports Microsoft.Visua lBasic
Imports System.Data.Sql Client
Imports System.Data
Imports CatsDsTableAdap ters
<System.Compone ntModel.DataObj ect()_
Public Class CntyAssetsAsset ManagementBLL
Private caamTa As CntyAssetsAsset ManagementTable Adapter
Protected ReadOnly Property Adapter() As
CntyAssetsAsset ManagementTable Adapter
Get
If caamTa Is Nothing Then
caamTa = New CntyAssetsAsset ManagementTable Adapter
End If
Return caamTa
End Get
End Property
<System.Compone ntModel.DataObj ectMethodAttrib ute(System.Comp onentModel.Data ObjectMethodTyp e.Select,
True)_
Public Function GetCntyAssetsAs setManagement() As
CatsDs.CntyAsse tsAssetManageme ntDataTable
Return Adapter.GetCnty AssetsAssetMana gement()
End Function
<System.Compone ntModel.DataObj ectMethodAttrib ute(System.Comp onentModel.Data ObjectMethodTyp e.Select,
False)_
Public Function GetCntyAssetsAs setManagement(B yVal whereClause As String)
As CatsDs.CntyAsse tsAssetManageme ntDataTable
Adapter.UpdateW here(whereClaus e)
Return Adapter.GetCnty AssetsAssetMana gement()
End Function
<System.Compone ntModel.DataObj ectMethodAttrib ute(System.Comp onentModel.Data ObjectMethodTyp e.Select,
False)_
Public Function GetCntyAssetByA ssetId(ByVal aid As Integer) As
CatsDs.CntyAsse tsAssetManageme ntDataTable
Return Adapter.GetCnty AssetByAssetId( aid)
End Function
<System.Compone ntModel.DataObj ectMethodAttrib ute(System.Comp onentModel.Data ObjectMethodTyp e.Update,
True)_
Public Function UpdateBatchCnty AssetsAssetMana gement(ByVal caamdt As
CatsDs.CntyAsse tsAssetManageme ntDataTable) As Boolean
For Each dr As CatsDs.CntyAsse tsAssetManageme ntRow In caamdt.Rows
If Not dr.IsAssetNumbe rNull Then
dr.AssetReviewe d = True
End If
If Not dr.IsAssetNotTr ackedNull AndAlso dr.AssetNotTrac ked = True
Then
dr.AssetReviewe d = True
End If
If Not dr.IsNoLongerCn tyAssetNull AndAlso dr.NoLongerCnty Asset =
True Then
dr.DateAssetDro pped = Now
End If
Next
caamdt.AcceptCh anges()
Adapter.Update( caamdt)
Return True
End Function
Public Sub UpdateWhere(ByV al where As String)
Adapter.UpdateW here(where)
End Sub
End Class
Imports Microsoft.Visua lBasic
Imports System.Data
Imports System.Data.Sql Client
Namespace CatsDsTableAdap ters
Partial Public Class CntyAssetsAsset ManagementTable Adapter
Private mSelectCommand As String
Public Sub UpdateWhere(ByV al where As String)
Me.InitCommandC ollection()
If mSelectCommand = "" OrElse mSelectCommand = String.Empty Then
mSelectCommand = Me._commandColl ection(0).Comma ndText
End If
Dim sql As String
If where = "" Then
sql = ""
Else
sql = " WHERE " & where
End If
Me._commandColl ection(0).Comma ndText = mSelectCommand & sql
End Sub
End Class
End Namespace
""Walter Wang [MSFT]"" <wa****@online. microsoft.comwr ote in message
news:aN******** *****@TK2MSFTNG HUB02.phx.gbl.. .
Hi SAL,
When you said "and a BusinessLogic layer using classes", do you mean the
class generated by the DataSet designer or your own class? I'm asking this
since the generated TableAdapter partial class also has this attribute:
Global.System.C omponentModel.D ataObjectAttrib ute(true),
If you defined your own custom BusinessLogic class and applied the
DataObjectAttri bute, could you please post some of your code to show how
you're using the TableAdapter?
Based on my understanding so far, you can create a partial class to the
TableAdapter and expose a public method or property to change the
CommandText of the select query to include your where clause. For example:
Namespace DataSet1TableAd apters
Partial Public Class authorsTableAda pter
Public Sub SetWhereClause( ByVal clause As String)
Me.InitCommandC ollection()
Me._commandColl ection(0).Comma ndText += " where " + clause
End Sub
End Class
End Namespace
Dim x As New DataSet1TableAd apters.authorsT ableAdapter
Dim ds As DataSet1.author sDataTable
x.SetWhereClaus e("phone like '4%'")
ds = x.GetData()
Hope this helps.
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.