Hi members
I have a DataTable from a database and after adding it to a CrystalReport nothing happen if i make the same to a GridView it populate the data successfully.
How i can populate the data to CrystalReport viewer?
This is my code
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim cn As New SqlConnection("server=192.168.2.200;database=stupremat;user=adm;password=Stupremat0@")
Dim stupremat2 As New SqlConnection("server=192.168.2.200;database=stupremat;user=adm;password=Stupremat0@")
Dim stupremat As New SqlConnection("server=192.168.2.200;database=stupremat;user=adm;password=Stupremat0@")
Dim substitution3 As New SqlConnection("server=192.168.2.200;database=SUBSTITUTION_SERVER;user=adm;password=Stupremat0@")
Dim tabEmp As New DataTable
tabEmp.Columns.Add("Emplacement")
tabEmp.Columns.Add("Articles")
tabEmp.Columns.Add("Substitution")
tabEmp.Columns.Add("Designation")
tabEmp.Columns.Add("Stock")
If cn.State = ConnectionState.Open Then
cn.Close()
End If
cn.Open()
Dim cmd2 As New SqlCommand("SELECT [DP_No],[DP_Code],[DP_Intitule],[DP_Zone] FROM [STUPREMAT].[dbo].[F_DEPOTEMPL] where DP_Intitule = 'A0013' order by DP_Intitule", cn)
Dim sqldata As New SqlDataAdapter(cmd2)
sqldata.Fill(tabEmp)
Dim rpt As New CRDemo
rpt.SetDataSource(tabEmp)
CrystalReportViewer1.ReportSource = rpt
CrystalReportViewer1.DataBind()
cn.Close()
End Sub
<asp:Button ID="Button1" runat="server" Text="Button" />
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="false" ToolPanelView="ParameterPanel" ReportSourceID="CrystalReportSource1" />
<CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
<Report FileName="CRDemo.rpt">
</Report>
</CR:CrystalReportSource>
<asp:GridView ID="GridView1" runat="server"></asp:GridView>