|
Are you sure that you have set the data source correctly in report designer (from the menu Report / Data Sources...)?
Mika
|
|
|
|
|
As you can see in my first post, i don't set any datasource in report designer, i want set all properties by code :
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=northwind;Integrated Security=True");
SqlCommand cmdSelect = new SqlCommand("select * from customers", con);
SqlDataReader dr;
DataTable dt = new DataTable();
DataSet ds = new DataSet();
con.Open();
dr = cmdSelect.ExecuteReader();
dt.Load(dr);
con.Close();
Microsoft.Reporting.WinForms.ReportDataSource rds = new Microsoft.Reporting.WinForms.ReportDataSource("Customers",dt);
this.reportViewer2.LocalReport.DataSources.Add(rds); this.reportViewer2.LocalReport.ReportEmbeddedResource= "ReportingServices.Report1.rdlc";
this.reportViewer2.RefreshReport();
|
|
|
|
|
Ok, you must define in the report definition (using designer) where the data is coming from. One way is to define a dataset and add that to report definition. After that you can add relevant fields to the report. At run time you can change the actual data by defining a new datasource, but that datasource must still have the fields (and tables) used in report definition.
Basically this is like data binding in UI. Try to define the datasource in designer, add a few fields in the report and then open the report in XML editor instead of designer. Because the report is only a XML definition, you can take a look at this and get a clear view what is actually happening when you design a report.
This article could also be useful to you: Creating Client Report Definition (.rdlc) Files[^]
Hope this helps,
Mika
|
|
|
|
|
Thanks Mika again
i know this, but my main problem is that how to access DataField's properties via code ?
|
|
|
|
|
I take it you're referring datafields in the report. Sorry to say but as far as I know there's no easy programmatic way (such as in UI or Crystal Reports).
The only way I know is to open the rdlc in xml format using for example XmlDocument class and read relevant elements from it and possibly modify them. Basically you can create the whole report on-the-fly by actually creating the xml formatted rdlc. For small reports it's quite easy but if the report definition is large, it can be quite painfull.
Mika
|
|
|
|
|
Hello,
This is my first post here I'm currently a high-school student learning C#.
I've made a small space-invaders/"blitz" video game.
The game is very simple, there's a group of aliens in the top of the screen, moving, and the player controls a space-ship that can shoot at the aliens.
After reading a few articles about threading I've decided that the easiest way for me to implement the moving of the aliens with the shootings and the space ship is to thread every operation, so every operation will have it's own timer (Actually a while loop with a Thread.Sleep())
I did that, but I'm getting an "InvalidOperationException - Object currently in use" from the methods that are trying to draw into the Graphics of the form, sometimes after firing a shot.
This is after using an AutoResetEvent, I've made sure that drawing to the graphics of the form occures in turns. But I'm still getting the error.
So I was wondering if anyone has a suggestion for me, even if it's without threading. I'm pretty sure I've used the ResetEvent on all the drawings. What causes the "object in use" other than drawing to it?
Thanks and sorry for the long post - I tend to write a lot. I hope I was clear - English isn't my mother language.
Uri.
|
|
|
|
|
You should draw in your paint event. You should not share the graphics object between threads. You should use threading to do things like calculate the positions of objects, so that your main thread is always free to just maintain the drawing operations.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
I see what you're saying, I'll try doing so.
I think I'll make a queue with a type I'll make for drawing and change the methods to instead of drawing,
sending it to the queue.
Thanks.
|
|
|
|
|
Sounds like a plan. Now, if you're game is not super simple, you may still have drawing issues. I believe the XNA framework exists to help people write games easily, uing DirectX. May be worth a look.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Yeah I told myself after I got the errors that GDI+ probably wasn't ment to be for this rather than building UIs.
After building a queue I'm still getting problems because it's too much drawings and the loop isn't fast enough to handle the queue which makes it stuck.
So I think I'm just gonna make a big loop that does everything one at a time and get it over with. Next game will be with DirectX or XNA
Thanks for all the help.
|
|
|
|
|
Threading just adds overhead and complexity for something like that.
There is mainly two things going on in your game:
1. Calculating how everyting is moving.
2. Draw it on the screen.
As #2 depends on the result of #1, there isn't really any reason to do these in separate threads. They would just be waiting for each other.
If you split up the work of #1 into a separate thread for each object that you display, it gets even worse. You need to synchronise each object, as you need to access the position of some object from other objects in order to detect collision, and you get a very complex model for something that is otherwise rather simple.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hello,
My application sends E-mail messages to an SMTP server for delivery but each SMTP server has its own configurations such as the number of messages it can send per day.I want your help in how to read or query these configurations.
Dad
|
|
|
|
|
How to save DataSet to exist MDB file?
|
|
|
|
|
With ADO.NET and SQL.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Hi everybody
I have a problem for open large file in C#.
While I want to open file with 100 MByte size(for example) and read its contents and show in the TextBox, program hanged.
If you know any solution about mentioned matter, I will become very happy for your assistance.
Thank you
Best Regards,
Reza Shojaee
|
|
|
|
|
That is way too much data to display in a TextBox. You need to rethink how you want to display the data. It's not possible to see more than a few kilobytes worth of text on the screen at once anyway.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi Guffa
My Problem not TextBox.
You suppose I want show data from file line by line into TextBox.
My problem is volume of file
Best Regards,
Reza Shojaee
|
|
|
|
|
You can read the file in another thread, this way your GUI should stay respondent. But I still wouldn't read it completely into memory, you will run into OutOfMemoryException s rather quickly. I'd suggest to read smaller chunks of the file as needed.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
A) It's only 100mb. He shouldn't be running out of memory.
B) When memory fills up, Windows pages to disk. He shouldn't be running out of memory.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Reza Shojaee wrote: My Problem not TextBox.
You suppose I want show data from file line by line into TextBox.
My problem is volume of file
Then I don't understand your question.
What is the problem exactly? What error message do you get?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
A string can theoretically only hold 2,147,483,647 characters. However, on a 32-bit OS, you never have that much contiguous memory available, so you'll probably never be able to create a string that large. Beyond that, no single array or structure can contain more than 1 billion items.
If you're running a 64-bit OS, you will realize larger strings, but you still might not be able to allocate their full size unless you have 4-8gb of RAM.
So, your problem is fragmented memory. With .Net, I'm not sure there's much you can do about it beyond allocating the string at program startup and hope you have enough unfragmented memory at that point. I would also use a StringBuilder object instead of a string because the constructor for a StringBuilder allows you to specify the size of the object, and you can put a try/catch block around the constructor call to make sure the framework didn't have any allocation problems.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Sunday, August 10, 2008 7:23 AM
|
|
|
|
|
Hi my friend
I think my problem with StreamReader solved
StreamReader sr = new StreamReader("c:\\1.psd");<br />
string line;<br />
<br />
while ((line = sr.ReadLine()) != null)
thank you for your helping
Best Regards,
Reza Shojaee
|
|
|
|
|
Also you can use this :
List<string> list = new List<string>();
using (StreamReader sr = new StreamReader(openFileDialog1.FileName))
{
while (sr.Peek() >= 0)
list.Add(sr.ReadLine());
}
|
|
|
|
|
Or simply:
string[] list = File.ReadAllLines(openFileDialog1.FileName);
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|