|
Okay. First, put double-quotes around your Extended Properties value array. This requirement is not documented, but the lack of quotations around the Extended Properties will mess up the parsing of the connection string (nice, huh? Love those semicolons - the universal separator ) resulting in the exception you're seeing. See below for an example connection string that's confirmed working...
Now, if that doesn't do it:
I don't have a PC without Excel on it at the moment, but I did make a little sample application to read data from Excel spreadsheets. I used the connection string:
string connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"c:\\mydocument.xls\";Extended Properties=\"Excel 8.0;HDR=Yes;\"";
in my application. One difference is the addition of the HDR extended property. You could also alternately choose to use IMEX as an extended property, but I don't think they'd make a lot of difference, but might be worth a try:
"HDR=Yes;" indicates that the first row contains columnnames, not data
"IMEX=1;" tells the driver to always read "intermixed" data columns as text
Failing all other solutions to your exception problem, I would have to guess that your server has a damaged or missing Indexed Sequential Access Method (ISAM) driver for Excel.
There's an article here[^] that discusses how the Jet Db engine is used to access Excel workbooks.
Here[^] is a link dealing with how to repair missing/corrupted ISAM files.
I hope this helps - after this I've got nothing...
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Ok, ill try with this. Thanks for all ur time. Ill let u know what happened
|
|
|
|
|
Hello,
I have:
this.dataview.Table = this.dataset.Tables["CashFlow"];<br />
dataview.RowFilter = "VersionID = "+Convert.ToInt32(versionID);
When I am using foreach statement to iterate through the dataview table, I can see all the rows, even the ones that have VersionID not equal to versionID specified in the RowFilter property. I thought if you provide the filter, only rows visible in the dataview are the ones that will have proper VersionID. Any ideas what I am doing wrong?
Thank you
|
|
|
|
|
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
|
|
|
|
|
|