Report Viewer using linq to sql and vb.net
Good morning, how to use the report viewer in vb.net using Linq to Sql?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Daniel RosaPosted Aug 11, 2014, 1:04 PM
What should I do to improve the code?
Private Sub TxtPesquisarNomeDocumento_TextChanged(sender As Object, e As EventArgs) Handles
TxtPesquisarNomeDocumento.TextChanged
Try
Dim ListaGeralPesquisaCodigoFuncao As IList(Of DAL.LT_DocIdentificacaoResult)
=
ListaGeralDocumentosIdent.Where(Function(w)
w.NOME_DOC_IDENTIFICAÇÃO.Contains(TxtPesquisarNomeDocumento.Text)).ToList()
CarregarGridDocumentos(ListaGeralPesquisaCodigoFuncao)
Catch ex As Exception
MsgBox("erro : " & ex.Message, MsgBoxStyle.Exclamation)
End Try
End Sub
Public Function DatagridviewToDataset() As System.Data.DataSet
Dim ds As New System.Data.DataSet
Try
'Add a new table to the dataset
ds.Tables.Add("Main")
'Add the columns
Dim col As System.Data.DataColumn
'For each colum in the
datagridveiw add a new column to your table
For Each dgvCol As DataGridViewColumn In DGVListaDocIdentificacao.Columns
col = New System.Data.DataColumn(dgvCol.Name)
ds.Tables("Main").Columns.Add(col)
Next
'Add the rows from the
datagridview
Dim row As System.Data.DataRow
Dim colcount As Integer =
DGVListaDocIdentificacao.Columns.Count - 1
For i As Integer = 0 To
DGVListaDocIdentificacao.Rows.Count - 1
row = ds.Tables("Main").Rows.Add
For Each column As DataGridViewColumn In DGVListaDocIdentificacao.Columns
row.Item(column.Index) =
DGVListaDocIdentificacao.Rows.Item(i).Cells(column.Index).Value
Next
Next
Return ds
Catch ex As Exception
'Catch any potential errors and
display them to the user
MessageBox.Show("Error Converting from
DataGridView" & ex.InnerException.ToString, _
"Error Converting from
DataGridView", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return Nothing
End Try
End Function
Thanks
Ramesh MaruthiPosted Aug 11, 2014, 10:23 AM
Please look at this links :)
http://blogs.msdn.com/b/bethmassi/archive/2009/08/19/using-the-reportviewer-with-ado-net-data-services-and-entity-framework.aspx
http://social.msdn.microsoft.com/Forums/en-US/7877c101-8920-4f3a-8a5e-0abe71f48c44/linq-as-a-datasource-for-reportviewer?forum=linqprojectgeneral