I have trouble rounding some cells from my datatable.
I want this round to 2 decimal places, as you can imagine. I will explain quickly how I charge data to the DataTable :
I have this function stored in a class:
Protected Friend Function cargarPref(ByVal id_Pref As String) As DataTable
Dim cmd As String = "Select Material,Cubicaje,SubTotal,ITBM,Total from Preferencia WHERE Id_Preferencia=#id_Pref"
Dim t As New DataTable
Try
con.Open()
comando = New OleDbCommand(cmd, con)
comando.Parameters.AddWithValue("#id_Pref", id_Pref)
adapter = New OleDbDataAdapter(comando)
adapter.Fill(t)
comando.Dispose()
adapter.Dispose()
con.Close()
Catch ex As Exception
MsgBox("Error en la consulta: " + ex.Message, MsgBoxStyle.Critical)
End Try
Return t
End Function
Ok, now I call it in my windows form:
Private Sub DataCliente_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataCliente.CellContentClick
If (Not IsNothing(DataMate)) Then
DataMate.DataSource = Nothing
mt.Clear()
End If
Dim index As Integer = 0
If (DataCliente.Columns(DataCliente.CurrentCell.ColumnIndex).Name.Equals("Empresa")) Then
index = Me.DataCliente.CurrentRow.Index
lblid.Text = DataCliente.Rows(index).Cells("Id_Cliente").Value
lblempresa.Text = DataCliente.Rows(index).Cells("Empresa").Value
lbldirecc.Text = DataCliente.Rows(index).Cells("Direccion").Value
lblcorreo.Text = DataCliente.Rows(index).Cells("Correo").Value
lbltel.Text = DataCliente.Rows(index).Cells("Telefono").Value
lblpreyd.Text = Math.Round(CDbl(DataCliente.Rows(index).Cells("PrecioYD").Value), 2).ToString("N2")
End If
mt = data.cargarPref(DataCliente.Rows(index).Cells("Id_Preferencia").Value) <--HERE!!!
DataMate.DataSource = mt
PanelMaterial.Enabled = True
End Sub
Now, watch as my values are in my database access, Along With the datagrid of the program!
For some strange reason ... the data I have taken from the database , the program treats them as if they were integers.
How I can then round off those values that are within the datatable, before printing in datagridview?
I finally discovered a solution , and I am going to show you how to solve this problem, if you need it (Before you do this , you must define all the columns you want to see on your datagridview !):
First, I create a class with public properties:
Public Class Preferencia
Public Property Material() As String
Public Property Cubicaje() As String
Public Property SubTotal() As String
Public Property ITBM() As String
Public Property Total() As String
End Class
Second , I create 2 functions and one procedural method :
Private Function setPreferencia(ByVal material As String, ByVal cubicaje As String, ByVal subtotal As String, ByVal itbm As String, ByVal total As String) As Preferencia
Dim item As New Preferencia
item.Material = material
item.Cubicaje = FormatNumber(cubicaje, 2)
item.SubTotal = FormatNumber(subtotal, 2)
item.ITBM = FormatNumber(itbm, 2)
item.Total = FormatNumber(total, 2)
Return item
End Function
Private Function registrarPreferencia() As List(Of Preferencia)
Dim lista As New List(Of Preferencia)
For Each itm In mt.Rows
lista.Add(setPreferencia(itm(0), itm(1), itm(2), itm(3), itm(4)))
Next
Return lista
Protected Friend Sub FillGrid()
DataMate.AutoGenerateColumns = False
DataMate.DataSource = registrarPreferencia()
DataMate.Columns("Material").DataPropertyName = "Material"
DataMate.Columns("Cubicaje").DataPropertyName = "Cubicaje"
DataMate.Columns("SubTotal").DataPropertyName = "SubTotal"
DataMate.Columns("ITBM").DataPropertyName = "ITBM"
DataMate.Columns("Total").DataPropertyName = "Total"
End Sub
Now the only thing is to call the method " FillGrid ()" when you want to print the data. And finaly, I resolved it!
Related
I have the following class :
Public Class titlesclass
Public Property Link As String
Public Property Title As String
Public Function Clear()
Link.Distinct().ToArray()
Title.Distinct().ToArray()
End Function
End Class
And the following code :
For Each title As Match In (New Regex(pattern).Matches(content)) 'Since you are only pulling a few strings, I thought a regex would be better.
Dim letitre As New titlesclass
letitre.Link = title.Groups("Data").Value
letitre.Title = title.Groups("Dataa").Value
lestitres.Add(letitre)
'tempTitles2.Add(title.Groups("Dataa").Value)
Next
I tried to delete the duplicated strings using the simple way
Dim titles2 = lestitres.Distinct().ToArray()
And calling the class function :
lestitres.Clear()
But the both propositions didn't work , i know that i'm missing something very simple but still can't find what it is
Easier to use a class that already implements IComparable:
Dim query = From title In Regex.Matches(content, pattern).Cast(Of Match)
Select Tuple.Create(title.Groups("Data").Value, title.Groups("Dataa").Value)
For Each letitre In query.Distinct
Debug.Print(letitre.Item1 & ", " & letitre.Item2)
Next
or Anonymous Types:
Dim query = From title In Regex.Matches(content, pattern).Cast(Of Match)
Select New With {Key .Link = title.Groups("Data").Value,
Key .Title = title.Groups("Dataa").Value}
For Each letitre In query.Distinct
Debug.Print(letitre.Link & ", " & letitre.Title)
Next
Ok, Since I notice you are using a ClassHere is one option you can do in order to not add duplicate items to your List within a class.I'm using a console Application to write this example, it shouldn't be too hard to understand and convert to a Windows Form Application if need be.
Module Module1
Sub Main()
Dim titlesClass = New Titles_Class()
titlesClass.addNewTitle("myTitle") ''adds successfully
titlesClass.addNewTitle("myTitle") '' doesn't add
End Sub
Public Class Titles_Class
Private Property Title() As String
Private Property TitleArray() As List(Of String)
Public Sub New()
TitleArray = New List(Of String)()
End Sub
Public Sub addNewTitle(title As String)
Dim added = False
If Not taken(title) Then
Me.TitleArray.Add(title)
added = True
End If
Console.WriteLine(String.Format("{0}", If(added, $"{title} has been added", $"{title} already exists")))
End Sub
Private Function taken(item As String) As Boolean
Dim foundItem As Boolean = False
If Not String.IsNullOrEmpty(item) Then
foundItem = Me.TitleArray.Any(Function(c) -1 < c.IndexOf(item))
End If
Return foundItem
End Function
End Class
End Module
Another option would be to use a HashSet, It will never add a duplicate item, so even if you add an item with the same value, it wont add it and wont throw an error
Sub Main()
Dim titlesClass = New HashSet(Of String)
titlesClass.Add("myTitle") ''adds successfully
titlesClass.Add("myTitle") '' doesn't add
For Each title As String In titlesClass
Console.WriteLine(title)
Next
End Sub
With all of that aside, have you thought about using a Dictionary so that you could have the title as the key and the link as the value, that would be another way you could not have a list (dictionary) contain duplicate items
I am trying to create a report which takes data from an sql query as a data source using this as an example.
Everything runs smoothly and all 3 test records are put into the array list. However when the report shows only one records is being shown.
Can you please tell me what I am doing wrong? Thank you
Record Class:
Public Class RecordGastoDotacion
Dim _id, _usuario As Integer
Dim _cantidad As String
Dim _fecha, _hora As String
Dim _desc As String
Public Sub New(ByVal id As Integer, ByVal fecha As Date, ByVal hora As Date, ByVal cantidad As String, ByVal descripcion As String, ByVal usuario As Integer)
Me._id = id
Me._fecha = fecha.ToString("dd/MM/yyyy")
Me._hora = hora.ToString("hh:mm:ss")
Me._cantidad = cantidad
Me._desc = descripcion
Me._usuario = usuario
End Sub
Public Property idgasto() As Integer
Get
Return _id
End Get
Set(ByVal Value As Integer)
_id = Value
End Set
End Property
Public Property fef() As String
Get
Return _fecha
End Get
Set(ByVal Value As String)
_fecha = Value
End Set
End Property
Public Property feh() As String
Get
Return _hora
End Get
Set(ByVal Value As String)
_hora = Value
End Set
End Property
Public Property cant() As String
Get
Return _cantidad
End Get
Set(ByVal Value As String)
_cantidad = Value
End Set
End Property
Public Property descr() As String
Get
Return _desc
End Get
Set(ByVal Value As String)
_desc = Value
End Set
End Property
Public Property usuario() As Integer
Get
Return _usuario
End Get
Set(ByVal Value As Integer)
_usuario = Value
End Set
End Property
End Class
Report creation:
Cmd.CommandText = String.Format("SELECT gas.idre_gasto as idgasto, date(fe.fecha) as fef, time(fe.fecha) as feh, gas.cantidad as cant, gas.descripcion as descr, gas.re_usuario_idre_usuario as usuario FROM re_gasto as gas INNER JOIN re_corte_caja AS cor ON gas.re_corte_caja_idre_corte_caja = cor.idre_corte_caja
inner join re_fecha as fe on cor.re_fecha_idre_fecha = fe.idre_fecha WHERE date(fe.fecha) BETWEEN '{0:yyyy-MM-dd}' AND '{1:yyyy-MM-dd}' AND cor.estatus = {2}",
DateTimePicker1.Value, DateTimePicker2.Value, ESTATUS_ACTIVO)
rs = Cmd.Execute
Dim listDataSource As New ArrayList()
Do While Not rs.EOF
listDataSource.Add(New RecordGastoDotacion(CInt(rs("idgasto").Value), CType(rs("fef").Value, Date), CType(rs("feh").Value, Date),
CType(rs("cant").Value, String), CType(rs("descr").Value, String),
CInt(rs("usuario").Value)))
rs.MoveNext()
Loop
Dim gastos As New ReporteGastos() With {.Margins = New Printing.Margins(100, 100, 25, 25), .DataSource = listDataSource}
gastos.XrLabel4.Text = String.Format("Día Creación: {0}", Now.ToString("dd/MM/yyyy"))
gastos.XrLabel5.Text = String.Format("Hora Creación: {0}", Now.ToString("hh:MM"))
gastos.AddBoundLabel("idgasto", New Rectangle(100, 20, 50, 30))
gastos.AddBoundLabel("fef", New Rectangle(150, 20, 100, 30))
gastos.AddBoundLabel("feh", New Rectangle(250, 20, 100, 30))
gastos.AddBoundLabel("cant", New Rectangle(350, 20, 50, 30))
gastos.AddBoundLabel("descr", New Rectangle(450, 20, 100, 30))
gastos.AddBoundLabel("usuario", New Rectangle(550, 20, 50, 30))
gastos.XrLabel12.Text = total
Using printTool As New ReportPrintTool(gastos)
printTool.ShowRibbonPreviewDialog(UserLookAndFeel.Default)
End Using
ReporteGastos:
Imports System.Drawing
Imports DevExpress.XtraReports.UI
Public Class ReporteGastos
Public Sub AddBoundLabel(ByVal bindingMember As String, ByVal bounds As Rectangle)
' Create a label.
Dim label As New XRLabel()
' Add the label to the report's Detail band.
Detail.Controls.Add(label)
' Set its location and size.
label.Location = bounds.Location
label.Size = bounds.Size
' Bind it to the bindingMember data field.
' When the dataSource parameter is Nothing, the report's data source is used.
label.DataBindings.Add("Text", Nothing, bindingMember)
End Sub
End Class
Output:
Refer the below documentation links to know that How binding of the ArrayList work with the XtraReport:
How to: Bind a Report to an Array List
Binding a Report to Lists
How to: Bind a Report to a Collection that Implements the ITypedList Interface
Providing Data to Reports
From your current code it should display multiple records if ArrayList contains multiple items. Please read documentation for XtraReport related to datasource assignment..
Check the example it is working as expected with your provided code snippet. It may be possible that you are some controls in report in wrong way. Please try to remove and add these added extra controls which are bind with the datasource one by one so that you can figure out control which causing problem.
What I want is to return 2 values from the database with a function and then store the values in variables so I can work with them. This is my code.
Function Buscar_Registro(ByVal xId As Integer) As String
Dim a, b As String
'convertir cadena
Dim Id As Integer
Id = xId
'conexión
Dim Conexion As OleDbConnection = New OleDbConnection
Conexion.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Visual\2000Phrases\2000 Phrases.accdb"
'cadena SQL
Dim CadenaSQL As String = "SELECT * FROM Data WHERE Id = " & Id
'Adaptador
Dim Adaptador As New OleDbDataAdapter(CadenaSQL, Conexion)
'Data set
Dim Ds As New DataSet
'Llenar el Data set
Conexion.Open()
Adaptador.Fill(Ds)
Conexion.Close()
'Contar registro
If (Ds.Tables(0).Rows.Count = 0) Then
Return False
Else
a = Ds.Tables(0).Rows(0)("Nombre").ToString()
b = Ds.Tables(0).Rows(0)("Apellido").ToString()
Ds.Dispose()
Return a
Return b
Return True
End If
End Function
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
Randomize()
Dim value As Integer = CInt(Int((20 * Rnd()) + 1))
TextBox3.Text = Buscar_Registro(value)
TextBox4.Text =
End Sub
I dont' know how to do it. The function returns only the value of "a"
Thanks
To return more values you need to change your function "as object"
Function Buscar_Registro(ByVal xId As Integer) As Object
and then you can put your return values into an object this way:
Return{a, b, true}
You'll get your values this way:
Dim mObj as object = Buscar_Registro(yourInteger)
you'll have:
a in mObj(0)
b in mObj(1)
True in mObj(2)
adapt it to your needs
EDIT (message to those that downvoted):
Creating a class an using a specific Object (the one created) to make a Function able to return multiple elements is surely the best choice.
Anyway, if someone doesn't know that it's possible to use the method that I showed in my answer, he is probably not (yet) able to create a class. So I think it's better give an usable (but not perfect) answer instead of a perfect (but unusable for the one who asked) answer.
This is what I think. Anyone can think differently.
Your best option here is to create your own class with the data you need and return that.
Public Class Data
Public Property Nombre As String
Public Property Apellido As String
End Class
And then do:
Function Buscar_Registro(ByVal xId As Integer) As Data
....
If (Ds.Tables(0).Rows.Count = 0) Then
Return Nothing
Else
a = Ds.Tables(0).Rows(0)("Nombre").ToString()
b = Ds.Tables(0).Rows(0)("Apellido").ToString()
Ds.Dispose()
return new Data() With {.Nombre = a, .Apellido = b}
End If
End Function
As of VB 15 you can use ValueTuple
Function Buscar_Registro(ByVal xId As Integer) As (Nombre As String, Apellido As String)
....
If (Ds.Tables(0).Rows.Count = 0) Then
Return (Nothing, Nothing)
Else
a = Ds.Tables(0).Rows(0)("Nombre").ToString()
b = Ds.Tables(0).Rows(0)("Apellido").ToString()
Ds.Dispose()
Return (a, b)
End If
End Function
I'm new to .net but wouldn't "ByRef" be the easiest way?
Function Buscar_Registro(ByVal xId As Integer, ByRef a As String, ByRef b As String)
I'm trying to retrieve my other football attributes (crossing, dribbling, finishing, ball control) that haven't been requested as arguments in the constructor- reportID, playerID and comments are all that are required.
There are over 20 football attributes, so I've just included the first few for readability.
Report Class:
Public Class Report
Public Sub New(ByVal reportID As Integer, ByVal playerID As Integer, ByVal comments As String)
_ReportID = reportID
_PlayerID = playerID
_Comments = comments
End Sub
Private _ReportID As Integer = 0
Private _PlayerID As Integer = 0
Private _Comments As String = ""
Private _Crossing As Integer = 0
Private _Dribbling As Integer = 0
Private _Finishing As Integer = 0
Private _BallControl As Integer = 0
Public Property ReportID() As Integer
Get
Return _ReportID
End Get
Set(ByVal value As Integer)
_ReportID = value
End Set
End Property
Public Property PlayerID() As Integer
Get
Return _PlayerID
End Get
Set(ByVal value As Integer)
_PlayerID = value
End Set
End Property
Public Property Comments() As String
Get
Return _Comments
End Get
Set(ByVal value As String)
_Comments = value
End Set
End Property
Public Property Crossing() As Integer
Get
Return _Crossing
End Get
Set(ByVal value As Integer)
_Crossing = value
End Set
End Property
Public Property Dribbling() As Integer
Get
Return _Dribbling
End Get
Set(ByVal value As Integer)
_Dribbling = value
End Set
End Property
Public Property Finishing() As Integer
Get
Return _Finishing
End Get
Set(ByVal value As Integer)
_Finishing = value
End Set
End Property
Public Property BallControl() As Integer
Get
Return _BallControl
End Get
Set(ByVal value As Integer)
_BallControl = value
End Set
End Property
End Class
Below I realise I'm only adding reportID, playerID and comments to my typeList, which is why I'm getting all 0's for my other attributes. How do access the attributes as well?
Retrieving the data:
Private Function retrieveReport() As List(Of Report)
Dim typeList As New List(Of Report)
Dim Str As String = "SELECT * FROM Report ORDER BY PlayerID"
Try
Using conn As New SqlClient.SqlConnection(DBConnection)
conn.Open()
Using cmdQuery As New SqlClient.SqlCommand(Str, conn)
Using drResult As SqlClient.SqlDataReader = cmdQuery.ExecuteReader()
While drResult.Read
typeList.Add(New Report(drResult("ReportID"), drResult("PlayerID"), drResult("Comments")))
End While
End Using 'Automatically closes connection
End Using
End Using
Catch ex As Exception
MsgBox("Report Exception: " & ex.Message & vbNewLine & Str)
End Try
Return typeList
End Function
Private Sub setReport()
For Each rpt As Report In retrieveReport()
'*****General Information
UC_Menu_Scout1.txtComments.Text = rpt.Comments
'*****Technical
UC_Menu_Scout1.UcAttributes1.lblXCrossing.Text = rpt.Crossing
UC_Menu_Scout1.UcAttributes1.lblXDribbling.Text = rpt.Dribbling
UC_Menu_Scout1.UcAttributes1.lblXFinishing.Text = rpt.Finishing
UC_Menu_Scout1.UcAttributes1.lblXBallControl.Text = rpt.BallControl
UC_Menu_Scout1.UcAttributes1.lblXPassing.Text = rpt.Passing
UC_Menu_Scout1.UcAttributes1.lblXHeadingAccuracy.Text = rpt.HeadingAccuracy
UC_Menu_Scout1.UcAttributes1.lblXMarking.Text = rpt.Marking
UC_Menu_Scout1.UcAttributes1.lblXTackling.Text = rpt.Tackling
'*****Mental
UC_Menu_Scout1.UcAttributes1.lblXAggression.Text = rpt.Aggression
UC_Menu_Scout1.UcAttributes1.lblXPositioning.Text = rpt.Positioning
UC_Menu_Scout1.UcAttributes1.lblXAnticipation.Text = rpt.Anticipation
UC_Menu_Scout1.UcAttributes1.lblXComposure.Text = rpt.Composure
UC_Menu_Scout1.UcAttributes1.lblXVision.Text = rpt.Vision
UC_Menu_Scout1.UcAttributes1.lblXTeamwork.Text = rpt.Teamwork
UC_Menu_Scout1.UcAttributes1.lblXWorkRate.Text = rpt.WorkRate
'*****Physical
UC_Menu_Scout1.UcAttributes1.lblXPace.Text = rpt.Pace
UC_Menu_Scout1.UcAttributes1.lblXBalance.Text = rpt.Balance
UC_Menu_Scout1.UcAttributes1.lblXJumping.Text = rpt.Jumping
UC_Menu_Scout1.UcAttributes1.lblXStrength.Text = rpt.Strength
UC_Menu_Scout1.UcAttributes1.lblXStamina.Text = rpt.Stamina
Next
End Sub
I imagine it's not that hard, so any help would be appreciated please!
To add values to the properties, use With:
typeList.Add(New Report(drResult("ReportID"), drResult("PlayerID"), drResult("Comments")) With {.BallControl = drResult("BallControl"), .Dribbling = drResult("Dribbling")})
You need to assign the property values that you aren't providing to the constructor as arguments, or you can add arguments to the constructor. Try this -- instead of calling the constructor like this:
typeList.Add(New Report(drResult("ReportID"), drResult("PlayerID"), drResult("Comments")))
instead, do this:
dim rep = New Report(drResult("ReportID"), drResult("PlayerID"), drResult("Comments"))
.Crossing = drResult("Crossing")
'additional property assignments
With rep
End With
typeList.Add(rep)
I've done some Googling but can't find anything concrete enough to go forward with, so here I am.
I have date fields that I am running a WHERE clause against, and returning fields based on that. The date fields are encrypted, so I was forced to take an alternative approach.
Dim aEmpList(dt.Rows.Count, 5) As String
Try
lCount = 0
For i As Integer = 0 To dt.Rows.Count - 1
If clsEncrypt.DecryptData(dt.Rows(i)(3)) >= 19500101 Then
aEmpList(lCount, 0) = clsEncrypt.DecryptData(dt.Rows(i)(0))
aEmpList(lCount, 1) = clsEncrypt.DecryptData(dt.Rows(i)(1))
aEmpList(lCount, 2) = clsEncrypt.DecryptData(dt.Rows(i)(2))
aEmpList(lCount, 3) = clsEncrypt.DecryptData(dt.Rows(i)(3))
aEmpList(lCount, 4) = clsEncrypt.DecryptData(dt.Rows(i)(4))
lCount = lCount + 1
End If
Next
Catch ex As Exception
MessageBox.Show(e.ToString())
End Try
clsEncrypt is an encryption/decryption class.
The fields are Employee First Name, Last Name, and Date of Birth - and they are all encrypted.
I am trying to find all Employees born>= 19500101, and return that data as a report.
I created a Structure and put the data as an array into the structure myStructure
'Define a structure to be used as source for data grid view.
Structure mystructure
Private mDim1 As String
Private mDim2 As String
Private mDim3 As String
Private mDim4 As String
Private mDim5 As String
Public Property Dim1() As String
Get
Return mDim1
End Get
Set(ByVal value As String)
mDim1 = value
End Set
End Property
Public Property Dim2() As String
Get
Return mDim2
End Get
Set(ByVal value As String)
mDim2 = value
End Set
End Property
Public Property Dim3() As String
Get
Return mDim3
End Get
Set(ByVal value As String)
mDim3 = value
End Set
End Property
Public Property Dim4() As String
Get
Return mDim4
End Get
Set(ByVal value As String)
mDim4 = value
End Set
End Property
Public Property Dim5() As String
Get
Return mDim5
End Get
Set(ByVal value As String)
mDim5 = value
End Set
End Property
End Structure
I populate the structure to load into a DataGridView for visualization purposes:
'populate structure with aEmpList array
Dim myarr(dt.Rows.Count) As mystructure
Try
For i As Integer = 0 To lCount - 1
myarr(i) = New mystructure With {.Dim1 = aEmpList(i, 0).ToString, .Dim2 = aEmpList(i, 1).ToString, .Dim3 = aEmpList(i, 2).ToString, .Dim4 = aEmpList(i, 3).ToString, .Dim5 = aEmpList(i, 4).ToString}
Next
Catch ex As Exception
MessageBox.Show(e.ToString())
End Try
DataGridView1.DataSource = myarr
Now that I've provided sufficient background, does anyone know what my next move should be?
I'm not sure how, or if, I should load the structure into a DataSet() [if that's even possible] or something of that nature.
As I see it you're trying to create a business class, and thus should use a reference type (Class) instead of a value type (Structure). So, the "next move" would be to change your structure to a class, implement INotifyPropertyChanged, IEditableObject, IChangeTracking, IRevertibleChangeTracking, and create a BindingList(Of T) to hold your items.
So, this kind of sucked to figure out, but I got it. As the question title says - I actually ditched the array portion because all it did was confuse me, and I went with the following solution:
Dim dt As New DataTable
Dim dts As DataSet = New DataSet()
With comm
.CommandText = "SELECT EMPL_ID, EMPL_FIRST_NM, EMPL_LAST_NM, BEG_DT, END_DT FROM EMPL"
End With
Dim adapter As New SqlDataAdapter(comm)
adapter.Fill(dts) 'Fill DT with Query results
dt.Load(dts.CreateDataReader())
Me.reportViewer1.RefreshReport()
Dim dts2 As New DataSet()
dts2 = dts.Clone
Try
Dim m As Integer
m = 0
For i As Integer = 0 To dts.Tables(0).Rows.Count - 1
If clsEncrypt.DecryptData(dts.Tables(0).Rows(i)(3)) >= "20130101" Then
dts2.Tables(0).Rows.Add()
dts2.Tables(0).Rows(m)(0) = clsEncrypt.DecryptData(dts.Tables(0).Rows(i)(0))
dts2.Tables(0).Rows(m)(1) = clsEncrypt.DecryptData(dts.Tables(0).Rows(i)(1))
dts2.Tables(0).Rows(m)(2) = clsEncrypt.DecryptData(dts.Tables(0).Rows(i)(2))
dts2.Tables(0).Rows(m)(3) = clsEncrypt.DecryptData(dts.Tables(0).Rows(i)(3))
dts2.Tables(0).Rows(m)(4) = clsEncrypt.DecryptData(dts.Tables(0).Rows(i)(4))
'dts2.Tables(0).Rows.Add(dts.Tables(0).Rows(i).cl)
m = m + 1
End If
Next
Catch ex As Exception
MessageBox.Show(e.ToString())
End Try
Dim rds As ReportDataSource = New ReportDataSource("DataSetDateOfBirthTest", dts2.Tables(0))
With reportViewer1
.LocalReport.DataSources.Clear()
.LocalReport.DataSources.Add(rds)
.RefreshReport()
End With