oledb

How to upload only non-empty rows of Excel spreadsheet using oledb in C#?

馋奶兔 提交于 2019-11-30 13:05:58
I am importing excel sheet to DataTable using oledb connection as below. private static DataTable UploadExcelSheet(string fileName) { DataTable uploadDataTable; using (OleDbConnection objXConn = new OleDbConnection()) { objXConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties=\"Excel 12.0;IMEX=1\""; objXConn.Open(); OleDbCommand objCommand = new OleDbCommand("SELECT * FROM Template$ ", objXConn); OleDbDataAdapter objDataAdapter = new OleDbDataAdapter(); // retrieve the Select command for the Spreadsheet objDataAdapter.SelectCommand =

Read a big Excel document

这一生的挚爱 提交于 2019-11-30 12:43:52
I want to know what is the fastest way to read cells in Excel. I have an Excel file that contains 50000 rows and I wanna know how to read it fast. I just need to read the first column and with oledb connection it takes me like 15 seconds. Is there a faster way? Thanks jiverson Here is a method that relies on using Microsoft.Office.Interop.Excel. Please Note: The Excel file I used had only one column with data with 50,000 entries. 1) Open the file with Excel, save it as csv, and close Excel. 2) Use StreamReader to quickly read the data. 3) Split the data on carriage return line feed and add it

The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine (server)

淺唱寂寞╮ 提交于 2019-11-30 12:09:08
问题 I know that is this question has dozen of answers and posts, but nothing works for me. I have my MVC 5 application and I deploy it to the IIS 7.5 to my server. Application runs great, everything is works until I go to the Action, where I use ACE.OLEDB. I'm getting this error: [InvalidOperationException: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.] System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString constr, DataSourceWrapper&

Is there a difference in the underlying protocol for ODBC, OLEDB & ADO.NET

六眼飞鱼酱① 提交于 2019-11-30 09:49:28
When communicating to a SQL Server database using one of the typical systems, ODBC, OLEDB or ADO.NET, is the underlying basic protocol the same? Are all the differences between these systems basically just client side issues? Is this all just different flavors of TDS (Tabular Data Stream) transfer? [MS-TDS]: Tabular Data Stream Protocol Specification Or there actual different ways to talk to the database server and there are fundamental difference between these protocols? ODBC, OLE DB and ADO.NET are different API/frameworks for communicating with the database. For example, ADO works on data

Can we add Reference of 'Microsoft.ACE.Oledb.12.0.dll' to project

时光怂恿深爱的人放手 提交于 2019-11-30 09:48:49
I am getting error "The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine." on my testing servers. So My Question is : i) Can i add reference for "'Microsoft.ACE.Oledb.12.0.dll'" to project it self? ii) Is it safe? iii) How to do this? Every thing is working on my local machine since i have latest version of office install in my machine. As soon as i am deploying my code to testing servers i am getting above error. I might not be able to install Office on testing servers (Due to some reason). So is it possible to put all require dll in project itself and deploy that to

Reading attached files from database using OLE-DB

倖福魔咒の 提交于 2019-11-30 09:30:07
问题 I'm trying to read a Microsoft Access Database using C#. I'm using the OLE-DB classes. The Problem is that this code OleDbDataReader reader = Command.ExecuteReader(); while (reader.Read()) { Console.WriteLine(reader.GetFieldType(0) + "\t" + reader.GetFieldType(1) + "\t" + reader.GetFieldType(2) + "\t" + reader.GetFieldType(3) + "\t" + reader.GetFieldType(4) + "\t" + reader.GetFieldType(5)); } tells me, that the 5th field is from the datatype string. But it's an attached file. When I'm trying

Jet Engine - 255 character truncation

旧城冷巷雨未停 提交于 2019-11-30 09:23:16
I'm needing to import an Excel spreadsheet into my program and have the following code: string connectionString = String.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;IMEX=1;HDR=NO;""", MyExcelFile.xls); command.CommandText = "SELECT * FROM [Sheet1$]"; (Note, code above isn't real code but should let you see what I'm doing) I'm getting the file imported, only problem is any columns in the Excel sheet which are over 255 characters are being truncated. Is there any way around this happening? I read somewhere that if you make sure there is a long line

Candlestick multiple Y values

邮差的信 提交于 2019-11-30 09:03:51
I am on a mission to make a candlestick graph using MSChart in a windows form. I already succeeded to make a 3D bar chart with no problems. But after a long search on the internet, Microsoft's source code (WinSamples) and a lot of headscratching I can't find the right way to create a candlestick graph. What could help me is a clear example of adding a serie to the chart with multiple Y-values or a correction of my code (when i run, debug nothing shows up exept for the legend label). A bonus would be that the example is based on OleDB (my values are in an Access database). So my question: If

Linked SQL Server database giving “inconsistent metadata” error

a 夏天 提交于 2019-11-30 08:29:13
I am currently running a third-party software suite, which uses SQL Server as its database. I have a second instance of SQL Server running in a different location, and some apps that I am building in that instance SQL Server needs to access some data in the third-party software. So, I created an ODBC connection between the boxes, and set up the third-party SQL server as a linked server on my version of SQL Server. As a test, I ran something like the following statement from my SQL server, accessing one of the third-party's tables: SELECT * FROM LinkedServerName.SchemaName.dbo.TableName To

Microsoft.ACE.OLEDB.12.0 CSV ConnectionString

偶尔善良 提交于 2019-11-30 08:23:58
问题 I know questions this kind are asked from time to time but i can't find any satisfying solution. How can I open a CSV-File using MS ACE OLEDB 12? I try it with the following code. DbConnection connection = new OleDbConnection(); connection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Documents;Extended Properties=\"Text;HDR=Yes\""; connection.Open(); DbCommand cmd; cmd = connection.CreateCommand(); cmd.CommandText = "SELECT * FROM [Mappe1#csv]"; DbDataReader reader =