|
That should work. Are you sure you are iterating through the dataview and not the datatable? You should have something like:
<br />
foreach (DataRowView drv in dataview)<br />
{<br />
}<br />
Can you post your looping code?
|
|
|
|
|
Yes I am positive, here is the loop that I am using:
<br />
for (int i = 0; i < this.dataview.Table.Columns.Count; i++) {<br />
foreach (DataRow val in this.dataview.Table.Rows) {<br />
if (val["IndentLevel"].ToString() == level && val["VersionID"].ToString() == row["VersionID"].ToString()) {<br />
total = total + Convert.ToDecimal(val[i]);<br />
} <br />
}<br />
row[i] = total;<br />
total = 0;<br />
}
|
|
|
|
|
You are, in fact, looping through the rows in the table, not the rows in the dataview. DataView.Table is a reference to the original, unfiltered table. You must loop through the DataRowView objects in the DataView itself as I showed you in my previous post.
Try this:
<br />
for (int i = 0; i < this.dataview.Table.Columns.Count; i++) {<br />
foreach (DataRowView val in this.dataview) {<br />
if (val["IndentLevel"].ToString() == level && val["VersionID"].ToString() == row["VersionID"].ToString()) {<br />
total = total + Convert.ToDecimal(val[i]);<br />
} <br />
}<br />
row[i] = total;<br />
total = 0;<br />
}
|
|
|
|
|
Thank you very much.
I realised that I was looping through the unfiltered table.
|
|
|
|
|
I have a binary file.I want to read it as a String.I read it as array of chars and then copy to a String variable.Then I write a string to the new binary file.
But output file content is not equal to the input file.
ex:// 1.bin is not equal to 2.bin
BinaryReader br;
BinaryWriter bw;
BinaryWriter bw=new BinaryWriter(File.Open("c:\\1.bin", FileMode.Create ));
string str=null;
br=new BinaryReader(File.Open("c:\\2.bin", FileMode.Open ,FileAccess.Read));
char[] ChArray=br.ReadChars(200);
for (int i=0;i<200;i++)
{
str=str+ChArray[i];
}
bw.Write(str);
br.Close();
bw.Close();
|
|
|
|
|
|
You can't read a binary file as text. Read it as bytes instead.
---
b { font-weight: normal; }
|
|
|
|
|
To read a binary as an array of bytes (with a lot of help from turbochimp):
using System.IO;
byte[] buffer = null;
Stream file = new FileStream(@"C:\myfile.bin", FileMode.Open, FileAccess.Read);
buffer = new byte[file.Length];
file.Read(buffer, 0, (int)file.Length);
file.Close();
Now, all the file contents are in "buffer" and you can work with it.
Hope it helps you.
|
|
|
|
|
Where i can find any information about creating a vector drawing software, about technical, and algorithm?. Thank you very much
Nothing
|
|
|
|
|
|
I think it hard to catch the events of line, rectangle,... Do you know any project about it?
Nothing
-- modified at 19:52 Thursday 29th September, 2005
|
|
|
|
|
Hi All,
I'm totally stymied trying to deserialize an xml document to an object that I created in a dynamic assembly:
exception:
"Unable to generate a serializer for type Person from assembly <unknown> because the assembly may be dynamic. Save the assembly and load it from disk to use it with XmlSerialization."
Before I post a pile of code, I hoped someone might have an insight to this problem. I have tried saving the assembly to disk, then reloading it using System.AppDomain.Load(byte[] rawAssembly,byte[] rawSymbolStore) from reading the dynamic dll and pdb from disk...
Everything works (the assembly is loaded and the types I defined dynamically can be reflected) until I get to the point of declaring the xml serializer for my type...
Arg. Help.
Rein
|
|
|
|
|
|
There is hope
Alas, loading a string AssemblyName raises this exception:
"The located assembly's manifest definition with name 'DynMod' does not match the assembly reference."
What do you suppose I am missing?
Rein
|
|
|
|
|
ooops,
disregard that... was using a different name for the assembly than the module. They're the same name now and the error is gone.
Thanks again,
Rein
|
|
|
|
|
typical story, new to c# and got a, probably stupid, question!
I am trying to compile the code at http://www.codeproject.com/dotnet/pinvokeaddshare.asp
Its intended to create a file share.
When I run the code it throws a System.Security.SecurityException.
I put the responcible line in a try | catch block, just in case it was a problem with the code and checked exceptions.
I examined the code and the return from the method called in the erroring line returns a status code which says that the share was created but it was not.
I am an admin of the locel machine, which is where I am creating the share.
What I am thinking now is that Visual Studio executes code in a sandbox kind of arrangement and a security level has to be specified for executing code!!! does this feature exsits?
Any ideas?
Thanks
|
|
|
|
|
|
typical story, new to c# and got a, probably stupid, question!
I am trying to compile the code at http://www.codeproject.com/dotnet/pinvokeaddshare.asp
Its intended to create a file share.
When I run the code it throws a System.Security.SecurityException.
I put the responcible line in a try | catch block, just in case it was a problem with the code and checked exceptions.
I examined the code and the return from the method called in the erroring line returns a status code which says that the share was created but it was not.
I am an admin of the locel machine, which is where I am creating the share.
What I am thinking now is that Visual Studio executes code in a sandbox kind of arrangement and a security level has to be specified for executing code!!! does this feature exsits?
Any ideas!
|
|
|
|
|
Hi
if I read command line args I get results of @"line\nline2"
how can I convert this into "line1\nline2"?
In other words: how to remove the '@'?
Ariadne
|
|
|
|
|
|
leppie wrote:
They are the same thing, the @ only defines different escaping routines.
ok, but how can I change the escaping routine.
if I do: sPrompt=args[i] and args[i] contains a '\' the real string of sPrompt is something like: @"...\...", but I want show this prompt in MessagBox without this '@' escape function. ie. I want show more than one line, if I get in args[i] a '\n'
thanks!
Ariadne
|
|
|
|
|
|
The escaping routine is for the compiler, and not for the string itself.
If you do Console.WriteLine("line1\\nline2") or Console.WriteLine(@"line1\nline2") , you'll get the same output:
line1\nline2 In the first case, to insert a backslash in the string, you need to double it (otherwise it will be interpreted as a special character: eg. \n as newline). In the second example, the @ means that a different escaping will be performed (most special characters won't be escaped) so \n produces exactly that, \n .
The @ makes a difference when specifying paths in code:
string path1 = "C:\\Program Files\\Microsoft";
string path2 = @"C:\Program Files\Microsoft"; In memory, both path1 and path2 will contain exactly the same.
If you read the string from anywhere typed by the user, you don't have to worry about escape characters. If he types one backslash, you'll get it. Escaping is only when specifying strings in code.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
Luis Alonso Ramos wrote:
The escaping routine is for the compiler, and not for the string itself.
no, I think not, because I get the '@'-problem at runtime.
but I'm happy leppie solved the problem with
sPrompt=sPrompt.Replace(@"\n","\n");
It works!
Thanks leppie
Ariadne
|
|
|
|
|
What that particular line of code is doing is replacing the characters \n (backslash followed by an n ) with an actual newline character. It is the exact equivalent of: sPrompt = sPrompt.Replace("\\n", "\n") .
Somehow you read the sPrompt string from somewhere that doesn't support escaping of characters (a resource maybe?) so you ended up with the characters '\' and 'n' in memory, instead of the actual newline (char 13) character.
But the escaping only works when specifying strings by code, and it's performed by the compiler.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|