oledb

SQL Server Destination vs OLE DB Destination

人走茶凉 提交于 2019-11-29 11:57:01
I was using OLE Db destination for Bulk import of multiple Flat Files. After some tuning I ended up with SQL Server Destination to be 25 - 50 % faster. Though I am confused about this destination as there are contradictory information on the web, some are against it, some are suggesting using it. I would like to know, are there any serious pitfalls before I deploy it to production? Thanks In this answer, I will try to provide information from official documentation of SSIS and I will mention my personal experience with SQL Server destination. 1. SQL Server Destination According to the official

C# Excel file OLEDB read HTML IMPORT

試著忘記壹切 提交于 2019-11-29 10:59:15
I have to automate something for the finance dpt. I've got an Excel file which I want to read using OleDb: string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=A_File.xls;Extended Properties=""HTML Import;IMEX=1;"""; using (OleDbConnection connection = new OleDbConnection()) { using (DbCommand command = connection.CreateCommand()) { connection.ConnectionString = connectionString; connection.Open(); DataTable dtSchema = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); if( (null == dtSchema) || ( dtSchema.Rows.Count <= 0 ) ) { //raise exception if needed }

OLEDB, Writing Excel cell without leading apostrophe

为君一笑 提交于 2019-11-29 10:50:41
I'm writing to Excel file using OLEDB (C#). What I need is just RAW data format. I've noticed all cells (headers and values) are prefixed by apostrophe (') Is it a way to avoid adding them in all text cells? Here is my connection string: string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties='Excel 8.0;HDR=Yes'"; I've tried use IMEX=1 like this: string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\""; But after that I'm receiving below error: The Microsoft

How to resolve “Could not find installable ISAM.” error for OLE DB provider “Microsoft.ACE.OLEDB.12.0”

扶醉桌前 提交于 2019-11-29 09:11:39
I am trying to import data from Excel 2007 (.xlsx) files into SQL Server 2008 using a T-SQL OpenRowset() command with the "Microsoft.ACE.OLEDB.12.0" OLE DB provider, and I'm getting a persistent "Could not find installable ISAM" error. All hardware is 32-bit. [Revised 1/10/12 to try to focus more sharply on the anomalies] The following T-SQL statement produces the error: SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Data Source=C:\work\TestData.xlsx;Extended Properties="Excel 12.0 XML;HDR=YES"', 'SELECT * FROM [Sheet1$]' ) If I save the Excel file in the "Excel 97-2003" format (.xls)

Insert DataTable into Excel Using Microsoft Access Database Engine via OleDb

本小妞迷上赌 提交于 2019-11-29 08:10:36
I came across instructions today for reading data from a Microsoft Excel file using an OleDbConnection on this website: OLE DB Providers This allows me to read in all the data from an Excel file: private const string EXCEL_CON = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};" + @"Extended Properties='Excel 8.0;HDR=Yes;IMEX=1;'"; public DataTable ExtractExcel(string fullFilename, string tableName) { var table = new DataTable(); string strCon = string.Format(EXCEL_CON, fullFilename); using (var xlConn = new System.Data.OleDb.OleDbConnection(strCon)) { ConnectionState initialState = xlConn

Problem with OleDbConnection, Excel and connection pooling

混江龙づ霸主 提交于 2019-11-29 05:18:46
So, I have the same symptoms as described in C#/ASP.NET Oledb - MS Excel read "Unspecified error" , but my my answer did not seem to fix it. Even always closing the OleDBConnection and disposing of it show the same symptoms. var connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0; data source={0}; Extended Properties=Excel 12.0;", _excelFile); using (var conn = new OleDbConnection(connectionString)) { try { DoSomething(); } finally { conn.Close(); } } Now I have found the following info on connection pooling: The .NET Framework Data Provider for OLE DB automatically pools

Dapper & MS Access - Read works, Write doesn't

谁说胖子不能爱 提交于 2019-11-29 04:08:51
Let's start by getting this out of the way: I'm stuck using an MS Access DB and I can't change it. This works fine: using (OleDbConnection conn = ConnectionHelper.GetConnection()) { conn.Open(); var results = conn.Query<string>( "select FirstName from Students where LastName = @lastName", new { lastName= "Smith" } ); conn.Close(); } This works fine: using (OleDbConnection conn = ConnectionHelper.GetConnection()) { OleDbCommand cmd = new OleDbCommand( "update Students set FirstName = @firstName, City = @city where LastName = @lastName", conn ); cmd.Parameters.AddWithValue("firstName", "John");

How to import an Excel file into SQL Server? [closed]

不打扰是莪最后的温柔 提交于 2019-11-29 02:34:55
What is the quickest way of getting my Excel file into a table in SQL Server? There are many articles about writing code to import an excel file, but this is a manual/shortcut version: If you don't need to import your Excel file programmatically using code you can do it very quickly using the menu in SQL Management Studio . The quickest way to get your Excel file into SQL is by using the import wizard: Open SSMS (Sql Server Management Studio) and connect to the database where you want to import your file into. Import Data : in SSMS in Object Explorer under 'Databases' right-click the

How to get list of ONLY excel worksheet names in Excel using OLEDB; filter out non-worksheets that show up in metadata

为君一笑 提交于 2019-11-29 01:00:06
问题 I have an issue getting worksheet names from an Excel spreadsheet using OLEDB. The problem is that when I use GetOleDbSchemaTable, the resulting DataTable has more than just the actual worksheet names; it has extra rows for "Tables" that I can only assume are used internally by Excel. So for example, if I have a worksheet named myWorksheet, the code below might end up with a list that contains myWorksheet$, myWorksheet$PrintTable and myWorksheet$_. Only the first myWorksheet$ record is for

Return value of a select statement

旧街凉风 提交于 2019-11-29 00:27:20
I have this little problem. I want to retrieve the resulting value of a select statement into a string variable. Like this OleDbCommand cmd1 = new OleDbCommand(); cmd1.Connection = GetConnection(); cmd1.CommandText = "SELECT treatment FROM appointment WHERE patientid = " + text; cmd1.ExecuteNonQuery(); I want the to place the selected treatment value into a string variable. How can i do this. Thanks Soner Gönül Use ExecuteReader() and not ExecuteNonQuery() . ExecuteNonQuery() returns only the number of rows affected. try { SqlDataReader dr = cmd1.ExecuteReader(); } catch (SqlException oError)