oledb

External table is not in the expected format when Excel file is closed

ぐ巨炮叔叔 提交于 2019-12-11 02:59:49
问题 My import works well with an .xls file, but it doesn't work with an .xlsx that I have created in Excel 2010, unless it is opened. My code looks like this: public static DataSet Sheets(string filePath, bool header) { DataSet dsResults = new DataSet(); string hasHeader = header ? "YES" : "NO"; OleDbConnectionStringBuilder sbConnection = new OleDbConnectionStringBuilder(); String strExtendedProperties = String.Empty; sbConnection.DataSource = filePath; if (Path.GetExtension(filePath).ToLower()

SSIS 2012 - Variable empty on second script execution

微笑、不失礼 提交于 2019-12-11 02:52:20
问题 I have a script component transformation in a data flow. In this script component I read a table from a object variable. The first record that passes through the script works fine. The variable reads correctly and loads into a list object perfectly. The next record passes into the script something goes wrong. Looking at the variable it reports a Record Count of 44, when it attempts to load into my list I get a rowcount = 0 Below is the script that loads the list List<PublicHoliday>

OleDBConnection Connection string

岁酱吖の 提交于 2019-12-11 02:46:21
问题 When I try this code OleDBConnection.open() not work and didn't throw any error, just open windows form and say anything I see messageBox try1 but program didn't show try2 what is the wrong in my connection string please help I've tried also excel 12.0 but it looks in reference Excel 14.0 in References (Microsoft Excel 14.0 Object Library) and the file is exist in c:\product.xlsx OleDbConnection conn_exel = new OleDbConnection(@"provider=Microsoft.Jet.OLEDB.12.0; Data Source=C:\product.xlsx;

Get column names from excel file of a specific sheet using c# with OleDbConnection

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 02:28:31
问题 So far I have managed to get the column names of the whole excel file, but what I would like to do is to get the column names of the excel file of a given table (sheet). How could I modify the code to achieve this. I have been trying for a while now with no positive results, any help much appreciated. public static List<String> ReadSpecificTableColumns(string filePath, string sheetName) { var columnList = new List<string>(); try { var excelConnection = new OleDbConnection("provider=Microsoft

How can I use named range in Excel with OleDB?

岁酱吖の 提交于 2019-12-11 02:18:58
问题 I'm trying to extract data from a specific named range in Excel with ASP .NET/C#. Here is an exemple of what I'm trying to extract. What I want is "B", "C", "D" by using the name "RANGE_NAMED". Is it possible to do this with OleDB ? Best regards, Alex. 回答1: You could try this code using(OleDbConnection c = new OleDbConnection(con)) { c.Open(); string selectString = "SELECT * FROM [RANGE_NAMED]"; using(OleDbCommand cmd1 = new OleDbCommand(selectString)) { cmd1.Connection = c; var result = cmd1

OleDbConnection opens sheet as read-only in any open Excel Window

╄→гoц情女王★ 提交于 2019-12-11 01:35:16
问题 This is pretty much exact question of : OleDbConnection() opens an Excel file in any open Excel window. But does not if there isnt a window open, but it had no answers. If I have multiple Excel windows open, my program will open a read-only sheet in any Excel window. I.e. if I have Test.xlsx open, and a blank sheet in another window (let's say my program wants to write to Test.xlsx); when I do: OleDbConnection myConn = new OleDbConnection(conn); myConn.Open(); a read-only copy of Test.xlsx

OleDbConnection string and unicode

谁都会走 提交于 2019-12-11 01:05:48
问题 In my program I'm reading data from a HTML file, in this file however there are sometimes pieces of text-data containing unicode characters wich get converted back to UTF-8 : Michèle --> Michèle I'm using the following code to retrieve the data from the file : string ConnectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"HTML import;CharacterSet=UNICODE;HDR=NO;IMEX=1;MaxScanRows=0;TypeGuessRows=0\";", fileName); using (OleDbConnection cn =

SSIS- OleDb Fast Load vs. Bulk Insert Task

▼魔方 西西 提交于 2019-12-10 23:55:27
问题 I have done research including threads on this forum but cant seem to find an answer. I am loading text files with 40 columns. No transformation at this time. There are 8 files ~25MB with a total of 1,400,000 rows. Using Bulk Insert task the load completes in 3 minutes. Using OleDb destination and flat file input connection manager the load completes in 30 minutes. From all I have read, SSIS should be using Bulk Inserts behind the OleDb connection. If so, why is there such a dramatic

Missing Required Parameter in Parameterized Query?

佐手、 提交于 2019-12-10 23:39:20
问题 I am getting the following error trying to execute the code below No Value Given For One Or More Required Parameters. string paraName = "CONTROL"; string fullPathToExcel = @"C:\Users\xbbjn2h\Desktop\Mapping.xlsx"; string connString = string.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 12.0 Xml;HDR=YES;""",fullPathToExcel); string sql = "SELECT [FUNCTION],[NAME] from [Sheet1$] WHERE [FUNTION] = ?"; OleDbConnection conn = new OleDbConnection(); conn

Custom LINQ provider for Excel spreadsheets?

拜拜、爱过 提交于 2019-12-10 20:42:16
问题 Does anyone know a good custom LINQ provider to query data from Excel spreadsheets? 回答1: The Linq to Excel open source project implements a simple and intuitive LINQ provider for getting data from Excel spreadsheets. It takes care of creating the OLEDB connection and sql statement in the background as well as populating the return object properties. For example, the code below reads the data from excel and returns a list of User objects. It automatically maps the column names in the