oledb

Month name of date field in Access database from external application (C#)

孤街浪徒 提交于 2019-11-29 15:52:47
I want to populate a drop down list at runtime in C#. I have a Date/Time field (e.g., 01/05/2000) in an Access 2003 database. I want to have the month name (i.e. January, February, ...) in the drop down list at runtime. SELECT DISTINCT MonthName(Month(DATE_OF_BOOKING)) AS MNTH FROM TRAVEL_DETAILS WHERE YEAR(DATE_OF_BOOKING)='2008' The above query works fine while I'm running it from Access directly, but when I'm trying to run it from an OledbCommand object in C# it says Undefined function 'MonthName' in expression. Text from social msdn thread : Custom user-written VBA functions as well as

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

限于喜欢 提交于 2019-11-29 15:47:38
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.CommandText = "INSERT INTO tblBooks (Title, Price, Tag, Author) VALUES (@title, @price, @tag, @author)"; cmd

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

邮差的信 提交于 2019-11-29 15:19:01
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 loadCustomerList() { DataTable dt = new DataTable(); using (OleDbConnection conn = new OleDbConnection

'Microsoft.ACE.OLEDB.12.0' 64x Sql Server and 86x Office?

做~自己de王妃 提交于 2019-11-29 15:17:55
问题 The error: OLE DB provider 'Microsoft.ACE.OLEDB.12.0' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode. And the answers I'm seeing is a conflict between 64 bit Sql Server and 32 bit Office. Is there a way to run an openrowset on Excel into Sql Server? insert into dbo.FiscalCalendar select * from openrowset('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0 Xml;Database=C:\Users\uname\Desktop\fy11.xlsx;', 'Select * from [Sheet1]') 回答1: ..

Getting values back from OleDbDataReader reading from Access database

岁酱吖の 提交于 2019-11-29 14:44:47
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 Access Database Engine OLE DB Provider;" + @"Data source= C:\Users\nearod\Desktop\ImportDB.accdb"; try {

Inserting a date/time value in Access using an OleDbParameter

岁酱吖の 提交于 2019-11-29 14:24:51
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. Wout OleDB doesn't like milliseconds in the datetime parameters. If you remove the milliseconds it will go ok. See also: How to truncate milliseconds off of a .NET DateTime . You could use. OleDbParameter objectdate = new

Jet Engine - 255 character truncation

China☆狼群 提交于 2019-11-29 14:11:18
问题 I'm needing to import an Excel spreadsheet into my program and have the following code: string connectionString = String.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;IMEX=1;HDR=NO;""", MyExcelFile.xls); command.CommandText = "SELECT * FROM [Sheet1$]"; (Note, code above isn't real code but should let you see what I'm doing) I'm getting the file imported, only problem is any columns in the Excel sheet which are over 255 characters are being truncated

Candlestick multiple Y values

旧街凉风 提交于 2019-11-29 12:53:05
问题 I am on a mission to make a candlestick graph using MSChart in a windows form. I already succeeded to make a 3D bar chart with no problems. But after a long search on the internet, Microsoft's source code (WinSamples) and a lot of headscratching I can't find the right way to create a candlestick graph. What could help me is a clear example of adding a serie to the chart with multiple Y-values or a correction of my code (when i run, debug nothing shows up exept for the legend label). A bonus

OpenXML takes much longer than OLEDB to read rows from Excel sheet

倾然丶 夕夏残阳落幕 提交于 2019-11-29 12:48:06
When I used OLEDB, it takes only 2 - 3 seconds to read 3200 rows from an Excel Sheet. I changed to the OpenXML format and now it takes more than 1 minute to read 3200 rows from an Excel Sheet. Below is my code: public static DataTable ReadExcelFileDOM(string filename) { DataTable table; using (SpreadsheetDocument myDoc = SpreadsheetDocument.Open(filename, true)) { WorkbookPart workbookPart = myDoc.WorkbookPart; Sheet worksheet = workbookPart.Workbook.Descendants<Sheet>().First(); WorksheetPart worksheetPart = (WorksheetPart)(workbookPart.GetPartById(worksheet.Id)); SheetData sheetData =

Check if column exists in OleDb table

心不动则不痛 提交于 2019-11-29 12:07:34
I am trying to check if a column exists and if not, add it. I've tried a couple of solutions including this , but the syntax isn't correct for Access db. This is what I have so far: public void Update(string task, string dbPath, string tableName = "Frames") { OleDbConnection db = new OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;data source=" + dbPath); db.Open(); OleDbCommand command = db.CreateCommand(); command.CommandText = "COL_LENGTH('Frames','SetNumber')"; Debug.WriteLine(command.ExecuteReader()); /* string[] restrictions = new string[] {null, null, tableName}; DataTable dtColumns =