Puiu Posted June 25, 2005 Posted June 25, 2005 I've decided to create a report based on an sql query...something like this: Dim SqlConn As New SqlConnection("Data Source=PUIUALEX;User Id=Puiu;password=puiu2108;" & _ "Initial Catalog=ImageLibrary;") Dim StrSql As String = "select Media.Description, Media.idmedia, count(*) as TotalDownloads from Media, Images, Requests where Media.idmedia=Images.idmedia AND Requests.idmedia=Media.idmedia AND Requests.aproved='T' group by Media.Description, Media.idmedia" Dim objDa As New SqlDataAdapter(StrSql, SqlConn) Dim objDs As New DataSet If SqlConn.State <> ConnectionState.Open Then SqlConn.Open() End If objDa.Fill(objDs) rpt.SetDataSource(objDs) CrystalReportViewer1.ReportSource = rpt DataBind() ----------------------------------------------------------------------- rpt=report document If I use the code above the report shows blank! If I use instead rpt.SetDataSource(objDs.Tables(0)) i get the error: Invalid Table Number. If i try to fill a datagrid instead of a report after the objDa.Fill(objDs) it works very well! Any clues ?? Quote
Puiu Posted June 26, 2005 Author Posted June 26, 2005 Ok, i've got it :cool: Let me explain, maybe it will help someone in the future: After i make the connection to the database instead of selecting a table or multiple tables i select to add a command: select Media.Description, Media.idmedia, count(*) as TotalDownloads from Media, Images, Requests where Media.idmedia=Images.idmedia AND Requests.idmedia=Media.idmedia AND Requests.aproved='T' group by Media.Description, Media.idmedia This command will generate the columns i need and wich i can drag now on my report If now i want to alter the information displayed i can simply modify the sqlString Cheers! :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.