Hi all,
I've started programming in VB.Net 2008 and need to clarify some concepts
around implementing Object Oriented Methodology and ADO.Net.

Sorry about the size of this question, but i'm really stuck here and need
other brains to shed some light :))

My case is the following, in simple terms:

There is a table Customers in SQL Server

*Customers*
----------------
IdCustomer
Name
Address

and there is an *object customer in VB.Net **with these properties:*
*
*
Public Class Customer
Private IdCustomer As String
Private Name As String
Private Address As String

Public Property IdCustomer_Cus()
        Get
            Return Me.IdCustomer
        End Get
        Set(ByVal value)
            Me.IdCustomer = value
        End Set
    End Property

Public Property Name_Cus()
        Get
            Return Me.Name
        End Get
        Set(ByVal value)
            Me.Name = value
        End Set
    End Property

Public Property Address_Cus()
        Get
            Return Me.Address
        End Get
        Set(ByVal value)
            Me.Address = value
        End Set
End Property
End Class

[and this method, in the data tier]

Public Class Customer_D
Public Function ShowCustomers() As List(Of Customer)
Dim CustomerList As New List(Customer)
Dim reader As SqlDataReader
Dim objCustomer As Customer
comand.CommandText = "SP_LIST_CUSTOMERS"  [comand has been defined already
with the connection to the database]

 [SP_LIST_CUSTOMERS is a stored procedure in SQL Server that selects all
                             from table Customers]

reader = comando.ExecuteReader()
While reader.Read()
            objCustomer = New Customer
            objCustomer.IdCustomer = reader.Item(0)
            objCustomer.Name = reader.Item(1)
            objCustomer.Addres = reader.Item(2)
End While
Return CustomerList
End Function
End Class

Now, in the load event for the form that lists customers, I've got:

Private Sub ShowCustomers_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
        iCustomer = New Customer

        DataGridView1.DataSource = iCustomer.ShowCustomers
        DataGridView1.Columns(" IdCustomer_Cus").HeaderText = "Customer ID"
        DataGridView1.Columns("Name_Cus").HeaderText = "Name"
        DataGridView1.Columns("Address_Cus").HeaderText = "Address"
End Sub


My idea here is to develop using OOP as it feels neat and tidy, but there
are a few things i'm not totally sure of:

- Is it more practical to just forget about object oriented design and
implement more straight forward ADO.Net with Data Adapters, Data Bindings
and Data Sources?

- Is there another way to implement ADO.Net with OOP that i'm not aware of?

- If I implement the OOP as mentioned, is there a way not to redefine the
column names in the datagridview, as they were already
defined in the Stored Procedure?

thanking you in advance!!

Daniela

-- 
You received this message because you are subscribed to the Google
Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
or visit the group website at http://megasolutions.net

Reply via email to