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 UpdateBatchCntyAssetsAssetManagement 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.VisualBasic
Imports System.Data.SqlClient
Imports System.Data
Imports CatsDsTableAdapters
<System.ComponentModel.DataObject()> _
Public Class CntyAssetsAssetManagementBLL
Private caamTa As CntyAssetsAssetManagementTableAdapter
Protected ReadOnly Property Adapter() As
CntyAssetsAssetManagementTableAdapter
Get
If caamTa Is Nothing Then
caamTa = New CntyAssetsAssetManagementTableAdapter
End If
Return caamTa
End Get
End Property
<System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select,
True)> _
Public Function GetCntyAssetsAssetManagement() As
CatsDs.CntyAssetsAssetManagementDataTable
Return Adapter.GetCntyAssetsAssetManagement()
End Function
<System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select,
False)> _
Public Function GetCntyAssetsAssetManagement(ByVal whereClause As String)
As CatsDs.CntyAssetsAssetManagementDataTable
Adapter.UpdateWhere(whereClause)
Return Adapter.GetCntyAssetsAssetManagement()
End Function
<System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select,
False)> _
Public Function GetCntyAssetByAssetId(ByVal aid As Integer) As
CatsDs.CntyAssetsAssetManagementDataTable
Return Adapter.GetCntyAssetByAssetId(aid)
End Function
<System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update,
True)> _
Public Function UpdateBatchCntyAssetsAssetManagement(ByVal caamdt As
CatsDs.CntyAssetsAssetManagementDataTable) As Boolean
For Each dr As CatsDs.CntyAssetsAssetManagementRow In caamdt.Rows
If Not dr.IsAssetNumberNull Then
dr.AssetReviewed = True
End If
If Not dr.IsAssetNotTrackedNull AndAlso dr.AssetNotTracked = True
Then
dr.AssetReviewed = True
End If
If Not dr.IsNoLongerCntyAssetNull AndAlso dr.NoLongerCntyAsset =
True Then
dr.DateAssetDropped = Now
End If
Next
caamdt.AcceptChanges()
Adapter.Update(caamdt)
Return True
End Function
Public Sub UpdateWhere(ByVal where As String)
Adapter.UpdateWhere(where)
End Sub
End Class
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.SqlClient
Namespace CatsDsTableAdapters
Partial Public Class CntyAssetsAssetManagementTableAdapter
Private mSelectCommand As String
Public Sub UpdateWhere(ByVal where As String)
Me.InitCommandCollection()
If mSelectCommand = "" OrElse mSelectCommand = String.Empty Then
mSelectCommand = Me._commandCollection(0).CommandText
End If
Dim sql As String
If where = "" Then
sql = ""
Else
sql = " WHERE " & where
End If
Me._commandCollection(0).CommandText = mSelectCommand & sql
End Sub
End Class
End Namespace
"Walter Wang [MSFT]" said:
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.ComponentModel.DataObjectAttribute(true),
If you defined your own custom BusinessLogic class and applied the
DataObjectAttribute, 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 DataSet1TableAdapters
Partial Public Class authorsTableAdapter
Public Sub SetWhereClause(ByVal clause As String)
Me.InitCommandCollection()
Me._commandCollection(0).CommandText += " where " + clause
End Sub
End Class
End Namespace
Dim x As New DataSet1TableAdapters.authorsTableAdapter
Dim ds As DataSet1.authorsDataTable
x.SetWhereClause("phone like '4%'")
ds = x.GetData()
Hope this helps.
Regards,
Walter Wang (
[email protected], 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.