By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 852 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

Reporting from DataTable

100+
P: 294
I have a DataTable that is populated from SELECT queries based on the parameters a user enters into text boxes. (First Name, Last Name or both)

I decrypt the values in the DataTable by using this code:
Expand|Select|Wrap|Line Numbers
  1.         Try
  2.             For i As Integer = 0 To dt.Rows.Count - 1
  3.                 dt.Rows(i)("FIRST_NM_TXT") = clsEncrypt.DecryptData(dt.Rows(i)("FIRST_NM_TXT"))
  4.                 dt.Rows(i)("LAST_NM_TXT") = clsEncrypt.DecryptData(dt.Rows(i)("LAST_NM_TXT"))
  5.             Next
  6.         Catch ex As Exception
  7.             MessageBox.Show("Either the first name or last name did not match. Please check your spelling.")
  8.         End Try
How can I use the information inside the DataTable to create a report? The values must be decrypted.

I have done some researching and I am confused as to why so many people use DataSets as opposed to DataTables. DataSets are a collection of Tables, are they not?

Should I first be converting the DataTable into a DataSet, and then using that?

Here is my code that populates the DataTable.
Expand|Select|Wrap|Line Numbers
  1.  SqlCommand.Connection = SQLConnection 'Assigns connection to the command
  2.  
  3.  
  4.  
  5.         If SearchFirsttxt.Text = "" Then
  6.             SqlCommand.CommandText = "Select * FROM PARTICIPANT WHERE LAST_NM_TXT = '" & eLast & "';"
  7.         ElseIf SearchLastTxt.Text = "" Then
  8.             SqlCommand.CommandText = "Select * FROM PARTICIPANT WHERE FIRST_NM_TXT = '" & eFirst & "';"
  9.         ElseIf SearchFirsttxt.Text IsNot Nothing And SearchLastTxt.Text IsNot Nothing Then
  10.             SqlCommand.CommandText = "Select * FROM PARTICIPANT WHERE FIRST_NM_TXT = '" & eFirst & "' and LAST_NM_TXT = '" & eLast & "';"
  11.         Else
  12.             SqlCommand.CommandText = "Select * FROM PARTICIPANT;"
  13.         End If
  14.  
  15.  
  16.         Dim myAdapter As New SqlDataAdapter(SqlCommand) 'holds the data
  17.         myAdapter.Fill(dt) 'datatable that is populated into the holder (DataAdapter)
  18.         DataGridView1.DataSource = dt 'Assigns source of information to the gridview (DataTable)
Thanks!
Feb 3 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.