J
Jim Coyne
I'm new to vb.net and need some help. I have to rewrite an application that
used VB6 COM objects in the middle tier for business rules and database
operations. They weren't really bound to anything (my understanding is
binding was a nightmare to attempt when this was written back around 2000),
but simulated binding so that when it became practical it could be done. A
brief example of how it is now:
[A Form]
Private m_objCustomerManager as CCustomerManager
Private m_objCustomer as CCustomerRecord
(in form_load)
Set m_objCustomerManager = New CCustomerManager
(in the GetCustomer_Click event)
intTheCustomerID = CInt(Trim(txtCustomerID.Text))
Set m_objCustomerRecord = m_objCustomerManager.Item(TheID:=intTheCustomerID)
ScreenPaint
(in the ScreenPaint)
If Not m_objCustomerRecord Is Nothing Then
With m_objCustomerRecord
Me.txtCustomerName.Text = .Name
End With
***
In the Manager object, the Item property works like this:
Public Property Get Item(ByVal TheID As Integer) As CCustomerRecord
cmdCustomerGet.Parameters("CustomerID") = TheID
(assign result of cmdCustomerGet to rsRec)
If rsRec.RecordCount = 0 Then
' set error condition, yadda yadda
Else
Set objCustomerRecord = New CCustomerRecord
With objCustomerRecord
.ID = rsRec("cust_id")
.Name = rsRec("cust_name")
End With
End If
Set Item = objCustomerRecord
End Property
*****
What I really need is a working example of how to do this by binding an
instance of CCustomerRecord to a Dataset (or Datatable), and then binding a
form's controls to the instance of CCustomerRecord. I'm totally confused
with the raw documentation that describes the binding context stuff and just
what to say it implements, and I haven't been able to find anything that
shows how to do the bindings between a dataset and a class itself.
Thanks,
Jim
used VB6 COM objects in the middle tier for business rules and database
operations. They weren't really bound to anything (my understanding is
binding was a nightmare to attempt when this was written back around 2000),
but simulated binding so that when it became practical it could be done. A
brief example of how it is now:
[A Form]
Private m_objCustomerManager as CCustomerManager
Private m_objCustomer as CCustomerRecord
(in form_load)
Set m_objCustomerManager = New CCustomerManager
(in the GetCustomer_Click event)
intTheCustomerID = CInt(Trim(txtCustomerID.Text))
Set m_objCustomerRecord = m_objCustomerManager.Item(TheID:=intTheCustomerID)
ScreenPaint
(in the ScreenPaint)
If Not m_objCustomerRecord Is Nothing Then
With m_objCustomerRecord
Me.txtCustomerName.Text = .Name
End With
***
In the Manager object, the Item property works like this:
Public Property Get Item(ByVal TheID As Integer) As CCustomerRecord
cmdCustomerGet.Parameters("CustomerID") = TheID
(assign result of cmdCustomerGet to rsRec)
If rsRec.RecordCount = 0 Then
' set error condition, yadda yadda
Else
Set objCustomerRecord = New CCustomerRecord
With objCustomerRecord
.ID = rsRec("cust_id")
.Name = rsRec("cust_name")
End With
End If
Set Item = objCustomerRecord
End Property
*****
What I really need is a working example of how to do this by binding an
instance of CCustomerRecord to a Dataset (or Datatable), and then binding a
form's controls to the instance of CCustomerRecord. I'm totally confused
with the raw documentation that describes the binding context stuff and just
what to say it implements, and I haven't been able to find anything that
shows how to do the bindings between a dataset and a class itself.
Thanks,
Jim