oledb

Retrieving values of the first column from Excel sheet (file with .xlsm extension) with OleDB

六眼飞鱼酱① 提交于 2019-12-24 00:46:16
问题 I am trying to retrieve values of the first column from the Excel sheet called "SP$". I have the path: string path = @"C:\Users\atsurkanu\Desktop" + @"\TemplateClientExtraction_IDEAFIMIT_Conero_QUARTER_20170127.xlsm"; string connectionString = string.Format(@"provider=Microsoft.ACE.OLEDB.12.0;data source={0};Extended Properties=Excel 12.0;", path); string sheetName = "SP$"; and some code like this one: using (OleDbConnection con = new OleDbConnection(connectionString)) { try { var dataTable =

Reading Excel files in a locale independent way

孤街浪徒 提交于 2019-12-24 00:35:24
问题 I am using the following code to read data from various Excel files: // IMEX=1 - to force strings on mixed data // HDR=NO - to process all the available data // Locale 1033 is en-US. This was my first attempt to force en-US locale. string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Locale Identifier=1033;Extended Properties=\"{1};READONLY=TRUE;HDR=NO;IMEX=1;\""; // source type according to the // http://www.microsoft.com/en-us/download/details.aspx?id=13255 // try

Classic ASP/OraOLEDB - how to define OUT param containing TABLE?

和自甴很熟 提交于 2019-12-24 00:32:06
问题 A classic ASP script migrated from msdaora to OraOLEDB will no long execute an Oracle SP it used to. The SP looks like this : TYPE tbl_CONSOLIDATED_ID IS TABLE OF VARCHAR2(32) INDEX BY BINARY_INTEGER; TYPE tblSAM_DD_TEXT IS TABLE OF VARCHAR2(50) INDEX BY BINARY_INTEGER; TYPE tblSAM_TYPE IS TABLE OF NUMBER INDEX BY BINARY_INTEGER; -- PROCEDURE Get_Associated_Samples( EMPID_IN IN MAS_EMPLOYEE.EMP_AUTOID%TYPE, ID_OUT OUT tbl_CONSOLIDATED_ID, SAMDDTEXT_OUT OUT tblSAM_DD_TEXT, SAMTYPE_OUT OUT

Unable to read xlsx file through OleDb with the size more than ~1mb

删除回忆录丶 提交于 2019-12-24 00:15:45
问题 I'd like to use sql bulk copy in order to load data from *.xlsx file to the data base. But, I've faced the problem when file size is more than approximately 1mb. When I try to open OleDbConnection I get an error No error message available, result code: E_FAIL(0x80004005) Does anyone have an idea about such behavior? P.S. If file size is less than mentioned above everything works as expected. string connString = connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended

Exception using DateTime in a parameterized OleDbCommand

╄→尐↘猪︶ㄣ 提交于 2019-12-23 23:25:58
问题 I'm trying to insert a System.DateTime into an Access database using a parameterized OleDbCommand in C#. However, it throws a Data type mismatch in criteria expression exception. Here is my code: string statement = "INSERT INTO Log (SCTID, LogDateTime, Type, Message, Visible)" + "VALUES (?, ?, ?, ?, ?);"; OleDbCommand insertCommand = new OleDbCommand(statement, connection); // Add parameters to the command insertCommand.Parameters.AddWithValue("@SCTID", OleDbType.Integer).Value = SCTID;

writing multiple tables on same excel sheet with oledb

僤鯓⒐⒋嵵緔 提交于 2019-12-23 23:22:32
问题 i'm creating excel file with xmlwriter and its become too large file about 250mb because of xml attribute and file type spreadsheet. i cannot use interop , because user doesnt want to set up office on server or 3rd part dll. Now i think , i should use Oledb for creating excel file . My problem is i cant write multiple table on same sheet with oledb. Error: data type mismatch in criteria expression My Code: connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended

In C# how to access excel headers using OLEDB (without Automation)?

本小妞迷上赌 提交于 2019-12-23 20:49:05
问题 This is my code where I am trying to access first row, first column string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + fileName + @";Extended Properties=""Excel 8.0;HDR=NO;"""; string CreateCommand = "SELECT * FROM [Sheet1$]"; OleDbConnection conn = new OleDbConnection(connectionString); conn.Open(); OleDbCommand cmd = new OleDbCommand(CreateCommand, conn); // cmd.ExecuteNonQuery(); DbDataReader dr= cmd.ExecuteReader(); int i = 0; while (dr.Read()) { string ab = dr

External table is not in the expected format.

喜你入骨 提交于 2019-12-23 20:25:13
问题 I am creating a small application to import excel data into my database, when i click the button it crashes with the error External table is not in the expected format. I tried googling and changing the codes here and there but the problem still occurs. I tried saving the file as a .xls and when i run the code the page went offline with google chrome's This webpage is not available (Cannot even enter debugging) Here is my code: string strConnection = ConfigurationManager.ConnectionStrings["--

Relative table links in ms-access

妖精的绣舞 提交于 2019-12-23 20:24:06
问题 I'm sure this must have been asked before, but I can't find it. Can I set a relative path for the location of a linked table in Access 2003? The other table is also stored in an mdb file. These databases will sometimes be connected to via odbc or oledb, so relying on vba code that fires when Access opens the file will not work. If possible I would like to keep the 'splitting' of the database invisible to the programs connecting, rather than them having to check each time that the correct

Server-side forward-only cursor breaks @@IDENTITY

醉酒当歌 提交于 2019-12-23 18:13:32
问题 Here is a minimal repro example. Database: CREATE TABLE temp (x int IDENTITY(1, 1), y int); Code (using VBA and ADO): Public Sub repro() Dim cn As New Connection Dim rs1 As New Recordset Dim cmd As New Command Dim rs2 As New Recordset cn.Open "Provider=SQLNCLI11;Server=myServer;Database=myDatabase;Trusted_Connection=Yes" rs1.Open "SELECT 1", cn, adOpenForwardOnly ' [X] ' cmd.ActiveConnection = cn cmd.CommandText = "INSERT INTO temp (y) VALUES (1) " cmd.Execute rs2.Open "SELECT @@IDENTITY", cn