oledb

How dump database table to excel sheet?

爱⌒轻易说出口 提交于 2019-11-28 11:28:58
问题 I am getting data from my database and I want to have that data as a table in excel file. So, I have written the following : Dim sheetToPopulate As Excel.Worksheet = getSheet() Dim reader As OleDbDataReader Dim query As String = "SELECT * FROM dataTable" Dim cmd As New OleDbCommand(query, oleConn) Dim reader As OleDbDataReader oleConn.Open() reader = cmd.ExecuteReader() Do While reader.Read() // How use the reader to populate the sheet at once. // I have the sheet object as sheetToPopulate. /

Loading Access DB Table to Datatable

风格不统一 提交于 2019-11-28 11:13:29
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 instead. How should I do it ? Justin Niessner string connString = "Provider=Microsoft.ACE.OLEDB.12.0;data

What is the fastest way to insert 100 000 records into an MDB file in C#

◇◆丶佛笑我妖孽 提交于 2019-11-28 09:42:35
问题 I know this questions is rather general, but I have searched the whole day and I haven't been able to find the proper way to do this. Here is my code to insert some 100 000 dummy records into an MDB file using C#. OleDbConnection con = new OleDbConnection(); string dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"; string dbSource = "Data Source = D:/programming/sample.mdb"; con.ConnectionString = dbProvider + dbSource; OleDbCommand cmd = new OleDbCommand(); cmd.Connection = con; cmd

Writing into excel file with OLEDB

雨燕双飞 提交于 2019-11-28 09:21:51
Does anyone know how to write to an excel file (.xls) via OLEDB in C#? I'm doing the following: OleDbCommand dbCmd = new OleDbCommand("CREATE TABLE [test$] (...)", connection); dbCmd.CommandTimeout = mTimeout; results = dbCmd.ExecuteNonQuery(); But I get an OleDbException thrown with message: "Cannot modify the design of table 'test$'. It is in a read-only database." My connection seems fine and I can select data fine but I can't seem to insert data into the excel file, does anyone know how I get read/write access to the excel file via OLEDB? Zorantula You need to add ReadOnly=False; to your

Getting values back from OleDbDataReader reading from Access database

ぐ巨炮叔叔 提交于 2019-11-28 08:59:21
问题 Below it the code I'm using to connect to an Access database and pull the values from the query. Problem is.. I cannot get any values back from the reader object. I can see that there are the correct amount of rows, however I keep getting an InvalidOperationException (whether I use GetValue() or GetString()) saying "No data exists for the row/column." System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(); conn.ConnectionString = @"Provider=Microsoft Office 12.0

The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine

梦想与她 提交于 2019-11-28 08:57:15
问题 Can someone help me with this error? When I try to open a connection to an mdb, I get "The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine" error. How can I correct this? My code is pretty simple: class ImportTDB { private string filename; private string connectionString; private int collisions = 0; public ImportTDB(String filename) { this.filename = filename; this.connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename; } public void

Load csv into oleDB and force all inferred datatypes to string

时光毁灭记忆、已成空白 提交于 2019-11-28 08:10:41
问题 Im trying to load a csv file into a datatable using oledb. This is no problem but unfortunately one of the fields which looks numeric has a string value in about 3% of the fields and so is not being populated. because im converting the csv into xml i really don't care about inferring datatypes and simply need the data in a string as i can cast it later in a Linq2XMl phase. I am hoping to be able to do this in the connection string. I don't want to just copy the table, set it up with new

Inserting a date/time value in Access using an OleDbParameter

不想你离开。 提交于 2019-11-28 08:00:38
问题 I'm trying to do an insert in oledb(ms access database) the field called objectdate is date/time the code i use to add the parameter is this, but i'm getting error. OleDbParameter objectdate = new OleDbParameter("@objectdate", OleDbType.DBDate); objectdate.Value = DateTime.Now; cmd.Parameters.Add(objectdate); the error: Data type mismatch in criteria expression. 回答1: OleDB doesn't like milliseconds in the datetime parameters. If you remove the milliseconds it will go ok. See also: How to

OLE DB vs OPEN XML SDK vs Excel.interop

蹲街弑〆低调 提交于 2019-11-28 07:42:36
I need to read XLSX files and extract a maximum amount of content from it. Which of the API's should I use? OLE DB, open XML SDK, or Excel Interop? Which is the easiest to use? Can you retrieve all the information using one or the other? i.e, date, times, merged cells, tables, pivottables, etc. You can try all of them and choose the one that fits you most... Depending on data you want to read, I'd suggest you to use Open XML over Interop or Ole DB. I don't know an open XML SDK, although I've some experience with EPPlus library which I'm using a lot and can say only good words about it - it's

Raw C++ code to display the names of tables in an SQL compact server using OLE DB

蹲街弑〆低调 提交于 2019-11-28 06:23:05
问题 Does anyone have a sample code that given the database file displays the names of all the user tables there? I am not interested in a .NET code, just the C++. I am trying to grok OLE DB to do the task - rocket science seems child play in comparison. 回答1: I'm going to assume SQL Server CE 3.0/3.1 but, for your reference, here are provider strings I'm aware of: SQL Server CE 3.0 / 3.1 - Microsoft.SQLLITE.MOBILE.OLEDB.3.0 SQL Server CE 3.5 - Microsoft.SQLSERVER.CE.OLEDB.3.5 Also, I will be