I got a code in which it is trying to read data from excel using OLEDB and populate the same into grid view. The grid was not populating with the values as desired. I debugged the code and I am getting a message like this.
enter image description here
I have installed Microsoft access database engine 2007 still it's not working. Please help me with this.
Related
I know questions like this are around in stack and there are 3rd part libraries to do the trick but none of them is fixing my issue at the moment. So the issue.
I have an Excel workbook (.xlsx) with multiple sheets generated by another system. I have to read the data from this via SSIS and dump it to a SQL DB.
Now the issue is although the Excel sheet contains data and when I open manually it opens without any error and the data displays when I use a script task and use OLEDB connection to connect to the excel and open it up the connection is made successfully but when reading data the column names are not picked (I get F1, F2 likewise) and no data rows are read. I simply get a blank row and that's about it. I have tried with HDR= YES and NO and IMEX=1 and 0 but always the result is same.
Funny thing is if I open the excel sheet do some modification (like change a sheet name save and change back the sheet name and save and close) and after that I try to run the package the data gets picked without any issue (also I noticed that the file size increases from 164KB to 196KB). Now because of this what am trying to do is modify the the file a bit and save via code.
So the initial step I tried was through using Office.Interop.Excel and it works like a charm in my machine but on the server NO OFFICE so IT NO WORKS. And nope the IT guys are never going to install access engine or excel or anything there.
Then I tried via OpenXML and 3rd party library like NPOI and even via OLEDB connection to modify the file. in both NPOI and OLEDB methods the file got changed but still it didn't get picked up properly by the SSIS package (I noticed that the file size didn't change and remained at 164kb). In OpenXML it wasn't able to open the file and threw an error saying "the document cannot be opened because there is and invalid part with an unexpected content type".
So right now I am stuck with no proper method in sight and would appreciate any help in solving this either through c# code or any other SSIS method available. SSIS version am using is 2008.
Edit 1
So I noticed that the script task is able to read the data from the first sheet out f the multiple sheets but the other sheets are the problem. So somewhere the xml for these sheets are broken. Anyway I can copy the xml configs of the first sheet to other ones? Just a thought...
Edit 2
So the first sheet is of ContentType "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" while all the other sheets are of ContentType "application/xml"
Ultimately ended up using two libraries for this. The data was read without an issue by using exceldatareader (http://exceldatareader.codeplex.com/). Using this the data was read into a dataset easily and then it was written to a new Excel file using epplus (http://epplus.codeplex.com/).
After that when the new excel file was read via the SSIS package data got picked without an issue. Hope this will help someone out there.
I have one Excel sheet, in that plenty amount of data is there, so need to write these data in the SQL server table directly. I searched in google but I didn't found a proper solution for my requirement.
My Excel contains the data in row wise, I mean that data is not continually provided. Having sub headings & some other information about tables description written after every table ended.
I hope you all understand my requirement. Please anybody have idea about this issue, or alternate solution to resolve. Have to store this excel data in to the SQL server table.
Here data is columns as rows & rows as columns. So how to read in this case.
firstname vijay vikram vikek varun
lastame kumar rathod goshal kandari
mobile 45425 456546 54656 454615
Like above my data in excel sheet so how capture this kind of data.
Did you try using a excel interop.Using interop you can even read particular cells.You can read values by specifying a range and build a datatable or list.
These links may help
http://sandeep-aparajit.blogspot.in/2008/08/how-to-read-excel-in-c.html
C#: Getting a cell's value with Excel.interop
If you want to insert data into db directly, without front-end functionality, then you can do it by using SSIS packages or import functionality available in SQL server
I have tried importing data from excel to sql server table. The process is in sql server right click on particular database and under tasks tab select import data option then select source excel file and destination table. It's working fine for me.
Thanks
Venkat
I would like to know the best way to read data from an uploaded excel document. Im currently using http://exceldatareader.codeplex.com/, which works good. The problem is that it cant read the values from checkboxes or radiobuttons. Im using asp.net framework 3.5. Any help is appreciated. Thanks
IF you have Excel installed on your system, you could include Microsoft.Office.Interop.Excel assembly and use that to do everything you need.
I am using the telerik rad controls in my asp.net web application. User can export any excel file say Test.xls. But when I try to import(Upload) Test.xls to Sql Server 2008. It gives error External Table is not in correct format. And the application crashes at the time of opening the Oledb connection. But if I create another Excel file say New.xls and import that file to my database, it works fine.
Can anyone help?
Thanks In Advance
Not really much that we can say with so little information. Best guess would be that your excel column data mappings don't match those required by the database.
New.xls may be a red herring if it doesn't contain any data.
Try and give us a little more information please regarding data and the exception - have you looked at the actual exception data by running this in debug in VS? If so what is it?
I'm working with MySQL connector and C#. Everything was ok until I got to the reporting part. There is no standard way to retrieve the data from MySQL to CrystalReport. So I read in this page that what I have to do is a XML file of a View created in MySQL then retrieve the data for Crystal Report. I dunno if you have done it but I am having problems with this.
When I put the information in the details section or when I group the information, the information is repeated and its driving me crazy. Do you have any idea why?
P.D.
I can't put any code because all is done in the UI of crystal report.
I got it, I think it was the mess of working with a XML file and then calling that to the CrytalReport, solution here:
http://writer.zoho.com/public/13706/27397
Use the mysql odbc driver to make a new connection in the database expert inside Crystal Reports.