Click here to Skip to main content
15,896,441 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I have This Class

Public Class PersonVO
Inherits ClientVO

Private _PersonFirstName As String
Private _PersonLastName As String
Private _PersonMiddleName As String


Public Property PersonFirstName() As String
Get
Return _PersonFirstName
End Get

Set(ByVal value As String)
_PersonFirstName = value
End Set
End Property


Public Property PersonLastName() As String
Get
Return _PersonLastName
End Get

Set(ByVal value As String)
_PersonLastName = value
End Set
End Property


Public Property PersonMiddleName() As String
Get
Return _PersonMiddleName
End Get

Set(ByVal value As String)
_PersonMiddleName = value
End Set
End Property

End Class


I Want to convert to Datatable or Dataset so i can easly saved in my Sql Database
Posted
Updated 10-Sep-13 12:41pm
v3

The short answer is: use ADO.NET. This CodeProject article can help you to get started: Using ADO.NET for beginners[^].

—SA
 
Share this answer
 
v2
Comments
Abhinav S 9-Sep-13 23:15pm    
5.
Sergey Alexandrovich Kryukov 10-Sep-13 0:28am    
Thank you, Abhinav.
—SA
Ahmad Al Halabi 10-Sep-13 18:53pm    
I rewrite My Question
You cannot store an object in your database.
YOu could serialize it. Though its easier to map class properties to database columns and then save them.
 
Share this answer
 
Comments
Ahmad Al Halabi 10-Sep-13 3:14am    
are you have any example ?
I Found The Solution
--------------------


Public Shared Function SetPersonDetails(ByVal PersonDetailsList As PersonVO) As DataTable
Dim dt As New DataTable()
Try
dt.TableName = "Person"

For Each [property] As PropertyInfo In PersonDetailsList.[GetType]().GetProperties()
dt.Columns.Add(New DataColumn([property].Name, [property].PropertyType))
Next


Dim newRow As DataRow = dt.NewRow()
For Each [property] As PropertyInfo In PersonDetailsList.[GetType]().GetProperties()
newRow([property].Name) = PersonDetailsList.[GetType]().GetProperty([property].Name).GetValue(PersonDetailsList, Nothing)
Next
dt.Rows.Add(newRow)
Return dt
Catch ex As Exception
Console.WriteLine(ex.ToString())
Return Nothing
End Try
End Function
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900