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. C#
  4. Having trouble closing crystal reports connection

Having trouble closing crystal reports connection

Scheduled Pinned Locked Moved C#
questionannouncementcsharpdatabasevisual-studio
4 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.
  • K Offline
    K Offline
    kornstyle
    wrote on last edited by
    #1

    I don't know if this is the correct place to post this but I didn't see any Message Board for Crystal Reports. I am using the Crystal reports version that comes with Visual Studio 2002. I have my reports opening in a separate form. The reports work fine but when I close the form it seems like the connection used by crystal reports is still open because I cannot do anything to my database. Sometimes it times out and sometimes I need to restart my program to release the connection. How do I close the connection between crystal reports and the database? I've been searching online and haven't found very much on this. Thanks.

    H 1 Reply Last reply
    0
    • K kornstyle

      I don't know if this is the correct place to post this but I didn't see any Message Board for Crystal Reports. I am using the Crystal reports version that comes with Visual Studio 2002. I have my reports opening in a separate form. The reports work fine but when I close the form it seems like the connection used by crystal reports is still open because I cannot do anything to my database. Sometimes it times out and sometimes I need to restart my program to release the connection. How do I close the connection between crystal reports and the database? I've been searching online and haven't found very much on this. Thanks.

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      How are you filling your ReportDocument? If you're using a DataSet then you're responsible for closing your connections. The DataAdater derivatives like OleDbDataAdapter and SqlDataAdapter do this manually but with connections you have to close them (or dispose them using the using block statement in C#). This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Customer Product-lifecycle Experience Microsoft [My Articles] [My Blog]

      K 1 Reply Last reply
      0
      • H Heath Stewart

        How are you filling your ReportDocument? If you're using a DataSet then you're responsible for closing your connections. The DataAdater derivatives like OleDbDataAdapter and SqlDataAdapter do this manually but with connections you have to close them (or dispose them using the using block statement in C#). This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Customer Product-lifecycle Experience Microsoft [My Articles] [My Blog]

        K Offline
        K Offline
        kornstyle
        wrote on last edited by
        #3

        I'm not using a dataset I made the connection using the Report Expert using the OleDb Connection. I am connecting to an access database.

        H 1 Reply Last reply
        0
        • K kornstyle

          I'm not using a dataset I made the connection using the Report Expert using the OleDb Connection. I am connecting to an access database.

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          So then the other thing I mentioned is still valid: dispose your connection. The C# using block statement is handy for that:

          using (OleDbConnection conn = new OleDbConnection("..."))
          {
          OleDbCommand cmd = conn.CreateCommand("...");
          // ...
          }

          This will make sure the connection is closed. If you don't want to close and re-open the connection all the time, defined your OleDbConnection as a field and in your Form's Dispose override call Dispose on your connection field inside the if block (that's where you free mananaged objects; outside the condition - so that it always runs - you free native resources like window and file handles). This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Customer Product-lifecycle Experience Microsoft [My Articles] [My Blog]

          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