|
This[^] article was in the Top 10 hits in a google search for ReportViewer example[^]
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
This[^] article was in the Top 10 hits in a google search for ReportViewer example[^]. See if that article, or any of those links gives you a good starting point.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Hi,
I’m loading XML into a DataSet using the following…
// Create a new Customer DataSet.
CustomerDS = new DataSet();
// Get a handle to the Customer.xml file.
CustomerFileHandle = new FileStream(CUSTOMERXMLFILEPATH, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
// Read the Customer XML file into the DataSet.
CustomerDS.ReadXml(new XmlTextReader(CustomerFileHandle));
This loads the information into the DataSet and it can all be viewed on my Form.
After making changes to my data, I then want to update the XML file. To do this I’m using the following code…
XmlTextWriter CustXmlWriter = new XmlTextWriter(CustomerFileHandle, System.Text.Encoding.Unicode);
// Write to the file with the WriteXml method.
CustomerDS.WriteXml(CustXmlWriter, XmlWriteMode.IgnoreSchema);
CustXmlWriter.Close();
// Close the Customer XML File.
CustomerFileHandle.Close();
This is not producing valid XML. All data (the xml) is being repeated at the end of the file with a NULL character in between each character.
Any help on this would be much appreciated.
Thanks in advance.
|
|
|
|
|
I am not sure why that isn't working. However, why don't you try taking a different taking a different route to your solution? Something like this:
CustomerDS = new DataSet();
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(XML_FILE);
xmlDocument.Save(XML_FILE);
Just a thought
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
How is it that I get my XML file into my DataSet?
|
|
|
|
|
just finished reading section 26.1 from C# specification.. I got a few questions regarding this new feature...
1. Why do we need "Implicitly typed local variables" (similar to "var" in JS)? Is it created especially for LINQ?? If LINQ is not used in the application, this kinda variable won't be required anymore, isn't it?
2. Let's say I wrote like that "var myvar = 1;". then, C# compiler will assume my variable "myvar" is int, right? Actually, I declared it as long.. What about "int vs uint", "long vs ulong" and "double vs float vs decimal"??
Since I haven't read about LINQ in details, I don't see any good point about using "Implicitly typed local variables"
What do you think?
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
"Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
|
|
|
|
|
Michael Sync wrote: Why do we need "Implicitly typed local variables" (similar to "var" in JS)? Is it created especially for LINQ?? If LINQ is not used in the application, this kinda variable won't be required anymore, isn't it?
It is not similar to var in js. A var in C# remains one type throughout once set.
var a = 5;
a = "five"; // This will throw a compiler error
Its inclusion is mainly to support LINQ. It is also required if you are using another new features called anonymous types. (What do you declare the reference if the type is anonymous)
Michael Sync wrote: Let's say I wrote like that "var myvar = 1;". then, C# compiler will assume my variable "myvar" is int, right? Actually, I declared it as long.. What about "int vs uint", "long vs ulong" and "double vs float vs decimal"??
You probably wouldn't use it in those situations. It wasn't what is is designed for. The only time is is REQUIRED is for anonymous types.
If you know the type then use the type.
Michael Sync wrote: What do you think?
I think it is something that I'll use from time to time when I need to use an anonymous type. However, if I know the type then I'll use the type. It is as simple as that.
However, I can forsee a lot of people getting it wrong then getting confused and asking questions about why they can't pass their variable into other methods or return it from a method.
|
|
|
|
|
Thanks a lot, Colin
Colin Angus Mackay wrote: anonymous types.
good point. ya... I missed it out... " Implicitly typed local variables" are good for LINQ and anonymous type, something that makes our code unreadable...
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
"Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
|
|
|
|
|
I see it as being handy when you create a new object of some type using reflection, when you don't know the type beforehand. Then, you have a strongly typed variable instead of just the interface or an object to work with. For example, lets say I implement a class that doesn't implement IList, but it comes close. So I write a method that takes an object, but the object must have an "Add" method. I think var may be helpful in this case, but only if you can do the following with it...
public void SomeMethod(object someObject) {
var foo = (someObject.GetType())someObject;
foo.Add(...);
}
As for the second question, you would have to explicitly state what type of variable it is. So you would have to say something like...
var f = 1f; // float
var u = (uint)1;
var l = (long)1;
etc.
Jeff
|
|
|
|
|
Skippums wrote: I see it as being handy when you create a new object of some type using reflection, when you don't know the type beforehand.
The thing is the compiler has to know the type. If it isn't an anoymous type (where the actual type is known only to the compiler) then you and the compiler should know the same thing. (I wrote a blog entry on what happens under the hood with anonymous types[^])
Skippums wrote: public void SomeMethod(object someObject) {
var foo = (someObject.GetType())someObject;
foo.Add(...);
}
I don't have VS2008 in front of me, but I doubt that is possible. The cast must be a literal or known at compiler time. This isn't.
|
|
|
|
|
Colin Angus Mackay wrote: I wrote a blog entry on what happens under the hood with anonymous types[^])
great one.. Thanks. I have subscribed your feed. Thanks..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
"Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
|
|
|
|
|
Michael Sync wrote: 1. Why do we need "Implicitly typed local variables" (similar to "var" in JS)? Is it created especially for LINQ?? If LINQ is not used in the application, this kinda variable won't be required anymore, isn't it?
They are only needed when the variable type is created in the compilation, so that it's impossible for you to explicitly declare a reference for it.
Michael Sync wrote: 2. Let's say I wrote like that "var myvar = 1;". then, C# compiler will assume my variable "myvar" is int, right? Actually, I declared it as long.. What about "int vs uint", "long vs ulong" and "double vs float vs decimal"??
The compiler will not assume that the variable is an int. The variable is an int, as you have specified a literal int value for it.
If you want a different data type, you have to specify a literal value of a different type. Like:
var first = 1U;
var answer = 42L;
var big = 1234567890UL;
var pi = 3.1416;
var size = 12.5F;
var price = 27.99M;
However, you should really never use this syntax with numeric literals, as it's not very obvious what the data type is.
A possible use where it makes sense, is where the data type is actually stated in the statement so that it's superflous to repeat it, like:
var b = new System.Web.UI.HtmlControls.HtmlInputRadioButton();
vs.
System.Web.UI.HtmlControls.HtmlInputRadioButton b = new System.Web.UI.HtmlControls.HtmlInputRadioButton();
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
thank you, Guffa. I'm clear now..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
"Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
|
|
|
|
|
I have a c# app that stores pdfs. I'd like to run a routine against the pdfs that changes them to searchable pdfs. Does anyone know how to accomplish this - I have adobe 8 on the server and not sure if there are any apis.
|
|
|
|
|
Hi,I'm writing a project in visual .net with C# platform and i want to use ReportViewer for creaing my reports,but I would like to know that how i can write codes in my ReoprtForm.cs for setting ReportViewer properties as like as page setup,setting margin ,fonts ,printing and so on ...
Thanks,
D.Riazi
D.Riazi
|
|
|
|
|
|
Hi, thanks for your response.but i don't want to creat any Report with Crystal Reporter.
I want to use Object Reporting with ReportViewer tool in C#.
D.Riazi
|
|
|
|
|
hi
In One System I am having One webservice.and in another system i have developed one Application that contain Only one textbox.
Actually in previous senario v r writing exceptions in eventlog or in trace.
but in my case,it has write tht perticular exception directly into TextBox with out saving r using files.please give me some suggestions to do.
thanks in advance
regards
prasanna
prasanna
|
|
|
|
|
Hi,
i have an c# Form implements AxMozillaBrowser control and
try to call the navigate method.
But I get the following error: "The operation timed out when attempting to contact http://www.google.de".
Im behind a proxy server. I put the proxy values in "about:config" .
Has anybody an idea?
thx in advance
|
|
|
|
|
Hi
Can any one tell me how to upload an Excell file to FTP using c#.
Thanks in advance
Prakash
PR
|
|
|
|
|
Uploading to an ftp doesn't depend on the type of file, it's the same process for all files. Did you try searching on google or codeproject? There are lots of examples showing how to do it
|
|
|
|
|
Following code is working fine for word document
but incase of excel it is in binary format
// Get the object used to communicate with the server.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://172.22.4.14" + @"/" + "E3764_DetailedLevelDesign.doc");
request.Method = WebRequestMethods.Ftp.UploadFile;
// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential("Danaher", "Motion$123");
// Copy the contents of the file to the request stream.
StreamReader sourceStream = new StreamReader("c://E3764_DetailedLevelDesign.doc");
byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);
response.Close();
when i try to open the excell file in IE it is not in redable format.
|
|
|
|
|
Reddy Prakash wrote: StreamReader sourceStream = new StreamReader("c://E3764_DetailedLevelDesign.doc");
byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
You are reading the file as if it was a text file, this doesn't work for any binary file. If you have managed to open .doc files uploaded with this code, you have only been lucky that the files have not been too badly corrupted.
Use the File.ReadAllBytes method to read the file into an array.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Thank you Guffa
|
|
|
|
|
Hi
How to start service in setup progress
i deploy a setup application for service
it's install but service don't start
i should manually start service
Finally
i would like to start service in installation progress(Amount Of Install)
Thanx
Boroumandan
|
|
|
|