Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Studio
  4. Cannot get my reports to work

Cannot get my reports to work

Scheduled Pinned Locked Moved Visual Studio
databasesharepointhelp
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    T0PGun
    wrote on last edited by
    #1

    Hi Guys, I am trying to build a report onto my application using VS2005(Cannot afford to upgrade even though I want to). The idea is to load data from my database into a dataset Item (Named DS_RPT_AssetStructure.xsd) using the table "TBL_AS" inside the dataset. I then have a report viewer (RV_AssetStructure) that links to a report (RPT_AssetStructure.rdlc). Now, when I run the report, I get back the error "A datasource instances has not been supplied for the datasource 'DS_RPT_AssetStructure_TBL_AS'. I have tried just designing the report to link directly to the dataset, and repointing the Datasources, but nothing seems to work. I really need to get this to work. Please can someone assist me. Here is my code that refreshes the report:

    Public Sub AssetStructureReport()
        Dim Con As New SqlConnection(Startup.TB\_Connect.Text)
        Dim Cmd As New SqlCommand("EXEC sp\_Rpt\_AssetStructure " & SQL.SetVar(RCM.CB\_Reports\_AssetStructure\_LocationID.Text), Con)
    
        RCM.Cursor = Cursors.WaitCursor
    
        Dim dsAS As New DS\_RPT\_AssetStructure
        Dim rs = New DS\_RPT\_AssetStructure.TBL\_ASDataTable
    
        Try
            Con.Open()
            Cmd.ExecuteNonQuery()
            Dim da As New SqlDataAdapter("SELECT \* FROM rpt\_RCM\_AssetStructure Order by \[AltSeq\]", Con)
    
            da.Fill(rs)
        Catch ex As Exception
            MsgBox("Error Running Asset Structure Report." & vbCrLf & ex.Message)
        Finally
            Con.Close()
            Con.Dispose()
        End Try
    
        MsgBox(rs.rows.count)
        RCM.RV\_AssetStructure.Reset()
        RCM.RV\_AssetStructure.LocalReport.ReportEmbeddedResource = "REW.RPT\_AssetStructure.rdlc"
        RCM.RV\_AssetStructure.LocalReport.DataSources.Clear()
        RCM.RV\_AssetStructure.LocalReport.DataSources.Add(New ReportDataSource("AS", rs))
        RCM.RV\_AssetStructure.Refresh()
        RCM.RV\_AssetStructure.RefreshReport()
    
        dsAS.Dispose()
    
        RCM.Cursor = Cursors.Arrow
    End Sub
    

    The msgbox i have there, is to confirm that my dataset has data, and I can confirm, that I am getting a row count back. If I comment out the following rows:

        RCM.RV\_AssetStructure.Reset()
        RCM.RV\_AssetStructure.LocalReport.ReportEmbeddedResource = "REW.RPT\_AssetStructure.rdlc"
        RCM.RV\_AssetStructure.LocalReport.DataSources.Clear()
        RCM.RV\_AssetStructure.LocalReport.DataSources.Add(New ReportDataSource("AS", rs))
        RCM.RV\_AssetStructure.Refr
    
    Richard DeemingR 2 Replies Last reply
    0
    • T T0PGun

      Hi Guys, I am trying to build a report onto my application using VS2005(Cannot afford to upgrade even though I want to). The idea is to load data from my database into a dataset Item (Named DS_RPT_AssetStructure.xsd) using the table "TBL_AS" inside the dataset. I then have a report viewer (RV_AssetStructure) that links to a report (RPT_AssetStructure.rdlc). Now, when I run the report, I get back the error "A datasource instances has not been supplied for the datasource 'DS_RPT_AssetStructure_TBL_AS'. I have tried just designing the report to link directly to the dataset, and repointing the Datasources, but nothing seems to work. I really need to get this to work. Please can someone assist me. Here is my code that refreshes the report:

      Public Sub AssetStructureReport()
          Dim Con As New SqlConnection(Startup.TB\_Connect.Text)
          Dim Cmd As New SqlCommand("EXEC sp\_Rpt\_AssetStructure " & SQL.SetVar(RCM.CB\_Reports\_AssetStructure\_LocationID.Text), Con)
      
          RCM.Cursor = Cursors.WaitCursor
      
          Dim dsAS As New DS\_RPT\_AssetStructure
          Dim rs = New DS\_RPT\_AssetStructure.TBL\_ASDataTable
      
          Try
              Con.Open()
              Cmd.ExecuteNonQuery()
              Dim da As New SqlDataAdapter("SELECT \* FROM rpt\_RCM\_AssetStructure Order by \[AltSeq\]", Con)
      
              da.Fill(rs)
          Catch ex As Exception
              MsgBox("Error Running Asset Structure Report." & vbCrLf & ex.Message)
          Finally
              Con.Close()
              Con.Dispose()
          End Try
      
          MsgBox(rs.rows.count)
          RCM.RV\_AssetStructure.Reset()
          RCM.RV\_AssetStructure.LocalReport.ReportEmbeddedResource = "REW.RPT\_AssetStructure.rdlc"
          RCM.RV\_AssetStructure.LocalReport.DataSources.Clear()
          RCM.RV\_AssetStructure.LocalReport.DataSources.Add(New ReportDataSource("AS", rs))
          RCM.RV\_AssetStructure.Refresh()
          RCM.RV\_AssetStructure.RefreshReport()
      
          dsAS.Dispose()
      
          RCM.Cursor = Cursors.Arrow
      End Sub
      

      The msgbox i have there, is to confirm that my dataset has data, and I can confirm, that I am getting a row count back. If I comment out the following rows:

          RCM.RV\_AssetStructure.Reset()
          RCM.RV\_AssetStructure.LocalReport.ReportEmbeddedResource = "REW.RPT\_AssetStructure.rdlc"
          RCM.RV\_AssetStructure.LocalReport.DataSources.Clear()
          RCM.RV\_AssetStructure.LocalReport.DataSources.Add(New ReportDataSource("AS", rs))
          RCM.RV\_AssetStructure.Refr
      
      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      T0PGun wrote:

      Dim Cmd As New SqlCommand("EXEC sp_Rpt_AssetStructure " & SQL.SetVar(RCM.CB_Reports_AssetStructure_LocationID.Text), Con)

      Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      T 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        T0PGun wrote:

        Dim Cmd As New SqlCommand("EXEC sp_Rpt_AssetStructure " & SQL.SetVar(RCM.CB_Reports_AssetStructure_LocationID.Text), Con)

        Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        T Offline
        T Offline
        T0PGun
        wrote on last edited by
        #3

        Thanks for the concern Richard, but it is not. The purpose of the SQL.SetVar function turns the whole thing into a string make SQLi harder to do, and then to further prevent it, the code in the SP cannot handle SQLi, and will instead fail with an error msg. Also, the CM_Reports_AssetStructure_LocationID object is also defined as a style DropDownList, so the users are restricted to certain values. I don't mean to sound rude and ungrateful, but I do appreciate your concern, but right now, I am more concerned about making the report work.

        Richard DeemingR 1 Reply Last reply
        0
        • T T0PGun

          Thanks for the concern Richard, but it is not. The purpose of the SQL.SetVar function turns the whole thing into a string make SQLi harder to do, and then to further prevent it, the code in the SP cannot handle SQLi, and will instead fail with an error msg. Also, the CM_Reports_AssetStructure_LocationID object is also defined as a style DropDownList, so the users are restricted to certain values. I don't mean to sound rude and ungrateful, but I do appreciate your concern, but right now, I am more concerned about making the report work.

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          But you're still using string concatenation to build your query. Can you be 100% sure that your SQL.SetVar function covers every single possible attack vector? Sure enough to justify having potentially vulnerable code for the sake of saving one extra line of code to add the parameter to your command in the correct way? Using parameterized queries in .NET isn't hard:

          Dim Cmd As New SqlCommand("EXEC sp_Rpt_AssetStructure @Param = @Param", Con)
          Cmd.Parameters.AddWithValue("@Param", RCM.CB_Reports_AssetStructure_LocationID.Text)

          ' -or-

          Dim Cmd As New SqlCommand("sp_Rpt_AssetStructure", Con)
          Cmd.CommandType = CommandType.StoredProcedure
          Cmd.Parameters.AddWithValue("@Param", RCM.CB_Reports_AssetStructure_LocationID.Text)


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          T 1 Reply Last reply
          0
          • Richard DeemingR Richard Deeming

            But you're still using string concatenation to build your query. Can you be 100% sure that your SQL.SetVar function covers every single possible attack vector? Sure enough to justify having potentially vulnerable code for the sake of saving one extra line of code to add the parameter to your command in the correct way? Using parameterized queries in .NET isn't hard:

            Dim Cmd As New SqlCommand("EXEC sp_Rpt_AssetStructure @Param = @Param", Con)
            Cmd.Parameters.AddWithValue("@Param", RCM.CB_Reports_AssetStructure_LocationID.Text)

            ' -or-

            Dim Cmd As New SqlCommand("sp_Rpt_AssetStructure", Con)
            Cmd.CommandType = CommandType.StoredProcedure
            Cmd.Parameters.AddWithValue("@Param", RCM.CB_Reports_AssetStructure_LocationID.Text)


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            T Offline
            T Offline
            T0PGun
            wrote on last edited by
            #5

            Okay, it is a good suggestion, and have made the change. Unfortunately, this has had no change to the result of my report. Kind Regards

            1 Reply Last reply
            0
            • T T0PGun

              Hi Guys, I am trying to build a report onto my application using VS2005(Cannot afford to upgrade even though I want to). The idea is to load data from my database into a dataset Item (Named DS_RPT_AssetStructure.xsd) using the table "TBL_AS" inside the dataset. I then have a report viewer (RV_AssetStructure) that links to a report (RPT_AssetStructure.rdlc). Now, when I run the report, I get back the error "A datasource instances has not been supplied for the datasource 'DS_RPT_AssetStructure_TBL_AS'. I have tried just designing the report to link directly to the dataset, and repointing the Datasources, but nothing seems to work. I really need to get this to work. Please can someone assist me. Here is my code that refreshes the report:

              Public Sub AssetStructureReport()
                  Dim Con As New SqlConnection(Startup.TB\_Connect.Text)
                  Dim Cmd As New SqlCommand("EXEC sp\_Rpt\_AssetStructure " & SQL.SetVar(RCM.CB\_Reports\_AssetStructure\_LocationID.Text), Con)
              
                  RCM.Cursor = Cursors.WaitCursor
              
                  Dim dsAS As New DS\_RPT\_AssetStructure
                  Dim rs = New DS\_RPT\_AssetStructure.TBL\_ASDataTable
              
                  Try
                      Con.Open()
                      Cmd.ExecuteNonQuery()
                      Dim da As New SqlDataAdapter("SELECT \* FROM rpt\_RCM\_AssetStructure Order by \[AltSeq\]", Con)
              
                      da.Fill(rs)
                  Catch ex As Exception
                      MsgBox("Error Running Asset Structure Report." & vbCrLf & ex.Message)
                  Finally
                      Con.Close()
                      Con.Dispose()
                  End Try
              
                  MsgBox(rs.rows.count)
                  RCM.RV\_AssetStructure.Reset()
                  RCM.RV\_AssetStructure.LocalReport.ReportEmbeddedResource = "REW.RPT\_AssetStructure.rdlc"
                  RCM.RV\_AssetStructure.LocalReport.DataSources.Clear()
                  RCM.RV\_AssetStructure.LocalReport.DataSources.Add(New ReportDataSource("AS", rs))
                  RCM.RV\_AssetStructure.Refresh()
                  RCM.RV\_AssetStructure.RefreshReport()
              
                  dsAS.Dispose()
              
                  RCM.Cursor = Cursors.Arrow
              End Sub
              

              The msgbox i have there, is to confirm that my dataset has data, and I can confirm, that I am getting a row count back. If I comment out the following rows:

                  RCM.RV\_AssetStructure.Reset()
                  RCM.RV\_AssetStructure.LocalReport.ReportEmbeddedResource = "REW.RPT\_AssetStructure.rdlc"
                  RCM.RV\_AssetStructure.LocalReport.DataSources.Clear()
                  RCM.RV\_AssetStructure.LocalReport.DataSources.Add(New ReportDataSource("AS", rs))
                  RCM.RV\_AssetStructure.Refr
              
              Richard DeemingR Offline
              Richard DeemingR Offline
              Richard Deeming
              wrote on last edited by
              #6

              T0PGun wrote:

              A datasource instances has not been supplied for the datasource 'DS_RPT_AssetStructure_TBL_AS'.

              T0PGun wrote:

              RCM.RV_AssetStructure.LocalReport.DataSources.Add(New ReportDataSource("AS", rs))

              Based on the error message, it looks like the data source in your report is called DS_RPT_AssetStructure_TBL_AS, but you're passing a data source called AS. Try changing the name to match:

              RCM.RV_AssetStructure.LocalReport.DataSources.Add(New ReportDataSource("DS_RPT_AssetStructure_TBL_AS", rs))


              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

              "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

              T 1 Reply Last reply
              0
              • Richard DeemingR Richard Deeming

                T0PGun wrote:

                A datasource instances has not been supplied for the datasource 'DS_RPT_AssetStructure_TBL_AS'.

                T0PGun wrote:

                RCM.RV_AssetStructure.LocalReport.DataSources.Add(New ReportDataSource("AS", rs))

                Based on the error message, it looks like the data source in your report is called DS_RPT_AssetStructure_TBL_AS, but you're passing a data source called AS. Try changing the name to match:

                RCM.RV_AssetStructure.LocalReport.DataSources.Add(New ReportDataSource("DS_RPT_AssetStructure_TBL_AS", rs))


                "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                T Offline
                T Offline
                T0PGun
                wrote on last edited by
                #7

                I wish you could see my face, It was that one line of code that has had me struggling for the past few days. But now it works. Thanks so much Richard. Now I can continue with my development. Kind Regards

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups