473,660 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Saving to XML file; something locks the file after first use; Any ideas?

I'm new to Crystal Reports, so this may be a dumb problem, but I just
can't figure it out.

Basically, I want to control the selected data in the C# code as
opposed to Crystal Reports (since SQL is truly for querying, and
Crystal Reports is more a reporting tool). The only way I've found to
do this so far is to execute my select in C#, then store to an XML
file, and then have the Crystal Report read the XSD and XML files.

However, I have a HUGE problem. I can only do this once (which works,
by the way), but then, something is locking the file, and I can no
longer access it. I can't delete it, and I can't write to it in my
code again. I close the document, but I'm not sure what else to do.
Even if I close out all applications (Visual Studio, Crystal Reports
XI, etc.), the file remains locked. The only way around it that I've
found is logging out and logging back in. Obviously, this is
unacceptable.

Ok, so here is my code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. CrystalDecisions.CrystalReports.Engine.ReportDocument doc = new
  3. CrystalDecisions.CrystalReports.Engine.ReportDocument() ;
  4.  
  5. doc.Load( @"C:\Development\CrystalReports\App1\CustomerProfile.rpt" ) ;
  6.  
  7. doc.SetDataSource( ds ) ;
  8.  
  9. string xsdFile =
  10. @"C:\Development\CrystalReports\App1\CustomerProfile.xsd" ;
  11. string xmlFile =
  12. @"C:\Development\CrystalReports\App1\CustomerProfile.xml" ;
  13.  
  14. ds.WriteXmlSchema( xsdFile ) ;
  15. ds.WriteXml( xmlFile ) ;
  16.  
  17. crystalReportViewer1.ReportSource = doc ;
  18. crystalReportViewer1.RefreshReport() ;
  19. crystalReportViewer1.Visible = true ;
  20.  
  21. doc.Close() ;
  22.  
  23.  
Does anyone have any idea what would be locking the XML file and why??
The XSD file can be written and rewritten, and it never becomes locked.
But the XML file does after running just once.

Any help is GREATLY APPRECIATED!!!

Feb 28 '06 #1
4 1852
On 28 Feb 2006 07:57:08 -0800, ch***********@g mail.com wrote:
I'm new to Crystal Reports, so this may be a dumb problem, but I just
can't figure it out.

Basically, I want to control the selected data in the C# code as
opposed to Crystal Reports (since SQL is truly for querying, and
Crystal Reports is more a reporting tool). The only way I've found to
do this so far is to execute my select in C#, then store to an XML
file, and then have the Crystal Report read the XSD and XML files.

However, I have a HUGE problem. I can only do this once (which works,
by the way), but then, something is locking the file, and I can no
longer access it. I can't delete it, and I can't write to it in my
code again. I close the document, but I'm not sure what else to do.
Even if I close out all applications (Visual Studio, Crystal Reports
XI, etc.), the file remains locked. The only way around it that I've
found is logging out and logging back in. Obviously, this is
unacceptable .

Ok, so here is my code:
[CODE SNIPPET]
Does anyone have any idea what would be locking the XML file and why??
The XSD file can be written and rewritten, and it never becomes locked.
But the XML file does after running just once.

Any help is GREATLY APPRECIATED!!!


Is the data you retrieve always in the same format?
If so, you could create an XSD within your project, create a class
instance of this XSD with the class which belongs to it, let the
adapter fill that class with data and only set the datasource for the
report:
Example:

DataSet oSet1 = null;
oSet1 = new RptTotalsQ(); // RptTotalsQ == XSD class
oAdap.Fill(oSet 1,"RptTotalsQ") ; // oAdap = SqlAdapter
oDoc = new MyReport(); // Report class
axCrystalActive XReportViewer1. ReportSource = oDoc;

Hope it helps --> the Crystal KB contains some of these samples in
full BTW

greetz, Leon
Feb 28 '06 #2
I don't know how to create a class instance of an XSD (I've never
really used XSDs before). I'm assuming you mean to add the XSD file to
the VS solution, and then create a class instance, correct? How do I
create the class instance?

And thanks for the info. As soon as I figure out how to create the
class, I'll give this a try. It sounds like exactly what I want to do.

Thanks!

- thephatp

Feb 28 '06 #3
On 28 Feb 2006 08:44:30 -0800, "thephatp" <ch***********@ gmail.com>
wrote:
I don't know how to create a class instance of an XSD (I've never
really used XSDs before). I'm assuming you mean to add the XSD file to
the VS solution, and then create a class instance, correct? How do I
create the class instance?

And thanks for the info. As soon as I figure out how to create the
class, I'll give this a try. It sounds like exactly what I want to do.

Thanks!

- thephatp

Explanation:
http://msdn.microsoft.com/library/de...netdataset.asp

greetz.
Leon
Feb 28 '06 #4
I'm not sure why the file remains locked like that, but you are doing
one step more than you need to.

If you design your report using the data source "More Data Sources" ->
ADO.NET (XML), and then point it to the XSD that you already have, then
there's no need to dump the data into an XML file. You can feed the
data to Crystal directly from your ADO.NET DataSet, using the
SetDataSource exactly as you did.

Of course, you have to get the XSD from somewhere, so that
WriteXmlSchema( ) line is useful the first time you run the program.
However, after that you don't need it any more.

The only hitch with doing it this way (with no XML file) is that in the
report designer you see only the field names, not sample data.

Feb 28 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
10136
by: simon place | last post by:
is the code below meant to produce rubbish?, i had expected an exception. f=file('readme.txt','w') f.write(' ') f.read() ( PythonWin 2.3 (#46, Jul 29 2003, 18:54:32) on win32. ) I got this while experimenting, trying to figure out the file objects modes,
138
6513
by: theodp | last post by:
--> From http://www.techdirt.com/articles/20040406/1349225.shtml Microsoft Patents Saving The Name Of A Game Contributed by Mike on Tuesday, April 6th, 2004 @ 01:49PM from the yeah,-that's-non-obvious dept. theodp writes "As if there weren't enough dodgy patents, here's an excerpt from one granted to Microsoft Tuesday for a 'Method and apparatus for displaying information regarding stored data in a gaming system': 'When saving a game,...
13
7400
by: Stuart McGraw | last post by:
I haven't been able to figure this out and would appreciate some help... I have two tables, both with autonumber primary keys, and linked in a conventional master-child relationship. I've created forms for both those tables, and inserted the child table form into the master table form as a subform. It works just as it is supposed to, in that I can create a new master record, and then add detail records.
5
3140
by: Thaynann | last post by:
I have an app that (at the moment) moves through files that are on a web site, and deletes them, wat i want to do for the next stage, is to be able to download each file before i delete it. i have tried POSTin to be able to view the image, then saving it, but it doesnt work, the problem i have is that all the files on the server have the same name, which is http://1.1.1.1/DH/repository/content.tif and for me to be able to view one, i...
9
2665
by: Tim_Mac | last post by:
hi, i'm not sure if i have chosen the best approach, but it seemed quite good to me. i have a collection class, containing business objects. the collection class is static and remains in-memory all the time the app is running. it is persisted to an Xml file when necessary. i keep a static filestream on the xml file. the advantage of this is that i can lock the filestream object to prevent concurrent reading/writing. the code works...
1
19919
by: ABCL | last post by:
Hi All, I am working on the situation where 2 different Process/Application(.net) tries to open file at the same time....Or one process is updating the file and another process tries to access it, it throws an exception. How to solave this problem? So second process can wait until first process completes its processing on the file. Thanks in advance
4
6718
by: Pedro Leite | last post by:
Good Afternoon. the code below is properly retreiving binary data from a database and saving it. but instead of saving at client machine is saving at the server machine. what is wrong with my code ?? thank you Pedro Leite From Portugal ------------------------------------
6
8112
by: Jeff | last post by:
Hey (and thank you for reading my post) In visual web developer 2005 express edition I've created a simple website project.. At this website I want users who register to be able to upload a picture of themselves to their profile... I admit that I'm a newbie... but this is how I understand this:
3
6578
by: fperri | last post by:
I have a DB in Access 2002 that when it is ran on a few users computers in the company, they get the error that the file sharing lock count has been exceeded and to increase the max locks per file in the registry. I have had them both increase the max locks per file in their registry to well above the amount of records in the DB. Actually, I had them set it to the same as my computer as I have never recieved the error. I have also had them...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8751
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4176
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4342
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.