Writing a project for a client using .NET 3.5 in C#. I need to import data from an XLS spreadsheet into a SQL data table. Problem is, one of the columns in the date table contains an "optional" date field. In the sample file provided by the client, no data exists in that optional field until row 27. The result is that NO ROW contains the optional field in the final SQL table.
I've been using an ODBC connection (MS Jet 4.0) to read the XLS. I tried adding MAXSCANROWS=0, which according to what I've read should allow the first 16384 rows to be used in determining column types. However, this seemed to have no effect.
I read another article that suggested the work-around is registry editing. That's not too practical, especially for deploying this project to the client's server.
Does anyone know another way to get the data to import correctly?
I've had nightmares trying exactly this kind of thing in Excel. That and the fact that if someone has the file open ODBC doesn't revert to a readonly mode as would happen if 2 people opened an xls file in the conventional manner.
As i remember if the first populated field within a column contains an integer you then get problems if subsequent fields contain text etc.
I think i ended up using the PIA approach and reading the data out cell by cell. It's slightly more laborious but gives a much finer level of control over what is happening
PIA approach? Can you point me in the direction of an article that would demonstrate how to read out the data cell by cell? I would have preferred this from the start, but I have been unable to find such information.
The primary interop assemblies are provided by microsoft so that you can access the Excel object model in c# code. Off the top of my head I believe that you have to have excel installed on the machine that's doing the processing.
Editing glyph IS NOT the black arrow, showing the row selected! The question is still actual. And I think the solution is to draw in row header. But what exactly? I'm sure somebody had already fixed this issue.
I solved the problem. As my CellPainting has already been overriden, I added such construction to clear the arrow:
using (Brush backColorBrush = new SolidBrush(e.CellStyle.BackColor))
e.Graphics.FillRectangle(backColorBrush, e.CellBounds.X+1, e.CellBounds.Y+1, 20,40);
There's not much you can do apart from drawing the X-button yourself and react to mouse clicks in the proper area. For this you need to derive your own control from TabPage.
See this articles how to do some owner drawing on a page control:
Just looked it up in Thunderbird by saving an e-mail in this format. It's basically just the mail header as received from the mail server (from, to, subject, mime, content-type, return-path) and the message body.
This, by definition, returns a hashtable, not a Product. That's what you said, right ? That returns a hash table, so you need to pull the value out of that hash table. I am surprised you don't get an invalid cast exception.
No longer a Microsoft MVP, but still happy to answer your questions.
Apologies if this is not in the correct forum, but hopefully someone can help with the below issue:
I have a C# Windows Service (.Net 2.0) that is to be installed on a collection of web servers in the DMZ. The Windows Service implements a FileSystemWatcher to check for changes to a set of specific CSV files held on a network share, and will copy locally any updated files before importing these to a local SQL database.
The distribution server that will hold the updated CSV files is also in the DMZ.
How can I set up the Windows Service / distribution server so that the service can access the network share securely? It seems that no matter how I set the service up i.e. running as LocalSystem, LocalService, NetworkService or a specific user account (can only be a local account as no access to AD in the DMZ) I get System.UnauthorisedAccessException's occuring when attempting to set up the FileSystemWatcher.
I created one page which contain one timer which will execute some function after every 5 min and send one mail to my id. Now the problem is i m not able to stop that one after every 5 min i receive mails. I close that page so it not execute but still it is running. How to stop that timer.
Last Visit: 29-Oct-20 13:15 Last Update: 29-Oct-20 13:15