oledb

Any references/manuals on SQL in EXCEL with Microsoft OLE DB Provider for Jet 4.0?

十年热恋 提交于 2019-12-17 23:22:36
问题 is there any references/manuals on SQL syntax in EXCEL connected with Microsoft OLE DB Provider for Jet 4.0 ? For example, how do I write constants of type date? What keywords/functions/clauses are available? 回答1: When using Excel as a Jet 4.0 data source, the best reference I know of is: How To Use ADO with Excel Data from Visual Basic or VBA. Of particular importance is how an existing column's overall data type is determined when it contains mixed data types. As regards the Microsoft OLE

MS Access, Named parameters and Column Names

耗尽温柔 提交于 2019-12-17 22:28:12
问题 I have the following query which I am executing on an Access database. The query, when run in Access returns accurate results. However when run from the code I get back all of the items in the database, even those which fall outside the date range I am searching for. I was wondering if the issue was because the parameter names are the same as the column names in the table, so I changed the parameter names @StartDate and @EndDate to be @FromDate and @ToDate and this fixed the problem, if the

Reading CSV file with OLEDB ignores first line even with HDR=No in Connection String

耗尽温柔 提交于 2019-12-17 21:19:10
问题 We're converting a Classic ASP site to an ASP.NET site. One function was to upload a 'template' of data in CSV format for importing into the database. There were several different record types in there (the first field always indentifies the type of data). The task was to get the CSV into a DataTable so it could be validated (new project is to have MUCH better validation rules) The code seemed pretty straightforward - watered down (taking out comments, Try/Catch, etc) it is as follows: Dim da

Loading Access DB Table to Datatable

*爱你&永不变心* 提交于 2019-12-17 19:48:44
问题 I have a database in .ACCDB format with some tables. I'm successfully loading it into an OleDbDataReader with the following code: string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;data source=C:\\marcelo.accdb"; OleDbConnection conn = new OleDbConnection(connectionString); string sql = "SELECT * FROM Clientes"; OleDbCommand cmd = new OleDbCommand(sql, conn); conn.Open(); OleDbDataReader reader; reader = cmd.ExecuteReader(); I'd like to load the table "clientes" to a datatable

What is the default value of IMEX in OLEDB?

一曲冷凌霜 提交于 2019-12-17 19:25:27
问题 string strConn = "Provider=Microsoft.Ace.OLEDB.12.0;Data Source=" + filename + ";Extended Properties=\"Excel 12.0 Xml;HDR=Yes;IMEX=1\";"; I search on google, and got no results. I think the default value is 2, but I am not sure. Anyone can help me? Thanks. 回答1: Per the article below, IMEX values of 0 and 2 do the same thing; they use ImportMixedTypes=MajorityType. That is the default if you don't specify IMEX=1 in your extended properties. So the default IMEX behavior is MajorityType, and

Getting the first sheet from an Excel document regardless of sheet name with OleDb

老子叫甜甜 提交于 2019-12-17 18:27:52
问题 I have users that name their sheets all sorts of crazy things, but I want to be able to get the first sheet of the Excel document regardless of what it is named. I currently use: OleDbDataAdapter adapter = new OleDbDataAdapter( "SELECT * FROM [sheetName$]", connString); How would I go about getting the first sheet no matter what it is named? Thank you. 回答1: ended up using this: using (OleDbConnection conn = new OleDbConnection(connString)) { conn.Open(); dtSchema = conn.GetOleDbSchemaTable

OleDB not supported in 64bit mode?

走远了吗. 提交于 2019-12-17 17:57:43
问题 I've been using Microsoft.Jet.OLEDB.4.0 and Microsoft.ACE.OLEDB.12.0 to read in .csv, .xls, and .xlsx files. I just found out that neither of these technologies are supported in native 64bit mode! I have 2 questions: What is the supported way to programatically read .csv, .xls, and .xlsx files in 64 bit mode. I just can't find answers to this anywhere. If I can't read in all three file types, what is the best way to read in .csv files in a 64 bit environment? Notes: I'm using .NET (3.5p1)

Quick ways to test OLE DB Connection String

最后都变了- 提交于 2019-12-17 17:39:15
问题 For debugging purpose I'd like to know ways to test OLE DB connection string quickly. I've found this free software, it works on my machine, tested successfully. Is there a even quicker way to do so, maybe from command line on Windows? Because most of the time, it is the client rather than me that would do this task, so I prefer a "zero-installation" approach that would impact their system the least. 回答1: If the client has PowerShell installed (a given if they are running Windows 7 or Windows

Data type mismatch in criteria expression | Access, OleDb, C#

橙三吉。 提交于 2019-12-17 16:29:20
问题 I read/update data from MS Access using C#. My code is: public static void UpdateLastLogin(int userid, DateTime logintime) ///logintime = DateTime.Now { string sql = @"UPDATE [Customers] SET [LastLogin]=?"; OleDbParameter[] prms = new OleDbParameter[] { new OleDbParameter("@LastLogin",logintime) }; using (DAL dal = new DAL()) { dal.UpdateRow(sql, false, prms); } } When it comes to Dates, I having trouble. This throws a "Data type mismatch in criteria expression." error. (I removed WHERE

Import Excel to Datagridview

给你一囗甜甜゛ 提交于 2019-12-17 15:59:09
问题 I'm using this code to open an excel file and save it in a DataGridView: string name = "Items"; string constr = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source=" + Dialog_Excel.FileName.ToString() + "; Extented Properties =\"Excel 8.0; HDR=Yes;\";"; OleDbConnection con = new OleDbConnection(constr); OleDbDataAdapter sda = new OleDbDataAdapter("Select * From [" + name + "$]", con); DataTable data = new DataTable(); sda.Fill(data); grid_items.DataSource = data; As explained on: This youtube