oledb

Generic Data Access functions

倖福魔咒の 提交于 2020-01-03 05:54:07
问题 What is the best way to code the following generic data access functions (ADO.NET, C# or VB, SQLServer or OLEDB) Execute SQL on a connection Open a DataReader Open a DataSet (any ideas on this one?) Such that I can call these functions from anywhere in my program. I'm not interested in Data Access patterns or Data Access layers unless they directly apply to these functions. (i.e. a pattern to automatically close the connection or the reader/dataset) Examples of use ExecuteSQL("UPDATE tblTest

The INSERT INTO statement contains the following unknown field name: 'a'. Make sure you have typed the name correctly, and try the operation again

旧巷老猫 提交于 2020-01-03 03:13:11
问题 // e,g, I want to insert 3 columns in 1st row and 10 columns in rest of the rows //I am Creating excel file with sheet name as MySheet // then updating value in 1st row, 1st cell of header as blank //then inserting data // Can anyone please help to insert data in excel without header string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Mode=ReadWrite;Extended Properties=\"Excel 12.0 XML;HDR=NO\""; using (OleDbConnection conn = new OleDbConnection

Filling DataGrid Columns w/ Excel Data in VB

痴心易碎 提交于 2020-01-03 02:57:12
问题 Alright, I finally got this code to work after hours of toiling: Dim path As String = OpenFileDialog1.FileName Dim myDataset As New DataSet() Dim strConn = New OleDbConnection("Provider=Microsoft.ACE.Oledb.12.0;Data Source=" & path & ";Extended Properties=""Excel 12.0;HDR=YES;IMEX=1""") Dim myData As New OleDb.OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn) myData.Fill(myDataset) DataGridView1.DataSource = myDataset.Tables(0).DefaultView Now that I figured that out I was going to try and

Using ADO to query text files - terrible performance

こ雲淡風輕ζ 提交于 2020-01-03 02:54:14
问题 I'm writing some code in VBA behind Excel to pull some summary numbers out of potentially huge text files (10M+ rows) out on a network drive. In the past, these numbers have been pulled using greps in linux, but I was hoping to implement something that could be done with a click of a button in Excel for ease of use. My solution works, but it's like 25 times slower than a linux grep - takes 4 minutes to query 10M records, while the grep can do it in 10 seconds. Should I not be using ADO for

Deadlock on bulk inserts

偶尔善良 提交于 2020-01-02 10:33:32
问题 I have several clients running an external executable using a C++ DLL to do bulk inserts though OLEDB into the same SQL Server table. The table has no indices, just a check constraint and a default. After I upgraded from SQL Server 2005 to 2008, all of a sudden I'm seeing deadlocks. The deadlock XDL (anonymized): <deadlock-list> <deadlock victim="process8057f048"> <process-list> <process id="process8057f048" taskpriority="0" logused="0" waitresource="OBJECT: 21:1176443315:0 " waittime="3329"

What's the difference between Jet OLEDB:Transaction Commit Mode and Jet OLEDB:User Commit Sync?

梦想与她 提交于 2020-01-02 10:26:12
问题 Althoug both Jet/OLE DB parameters are relativly well documented I fail to understand the difference between these two connection parameters: The first one: Jet OLEDB:Transaction Commit Mode (DBPROP_JETOLEDB_TXNCOMMITMODE) Indicates whether Jet writes data to disk synchronously or asynchronously when a transaction is committed. The second one: Jet OLEDB:User Commit Sync (DBPROP_JETOLEDB_USERCOMMITSYNC) Indicates whether changes that were made in transactions are written in synchronous or

Why connecting to an OLEDB is giving me an connection error

久未见 提交于 2020-01-02 07:43:12
问题 I have the following code which is connecting to my database and retrieving some data from a table: string connectionString = "Data Provider=SQLOLEDB;Data Source=myserver;Initial Catalog=Db;Integrated Security=FALSE;user=zh;pwd=zh12;"; using (OleDbConnection connection = new OleDbConnection(connectionString)) { connection.Open(); OleDbCommand command = new OleDbCommand(); command.Connection = connection; command.CommandText = "SELECT [Location], [URL], [TAGS] FROM [Db].[dbo].[BOOKINGTABLE]";

Force an OleDbConnection to Release a File Handle

故事扮演 提交于 2020-01-02 07:00:28
问题 Related Question My code doesn't release a file handle even after I call dispose to an initialized OleDbException. Is there a way to explicitly force the program to release a file handle? 回答1: By default, .NET database connections use pooling. Calling Close() and Dispose() just releases the connection back into the pool, it doesn't actually force it to close. Eventually it will time out of the pool, and actually be closed. After a bit of research, there seem to be two main ways to get it

Query Excel spreadsheet with C# .NET without using Jet OLE DB

☆樱花仙子☆ 提交于 2020-01-02 03:11:08
问题 Is there any way to query an excel 2010 spreadsheet, without using Jet or exporting as a CSV and querying the csv file. The reason why I cannot use Jet is because the application needs to run as a web service, on Windows Server 2008 R2, with no 32 bit support - hence Jet will not work. This is a given, as WOW 64 is not installed on the target server. This thread suggests using a 32 bit proxy machine, but this is also not an option. Further info: The server is running Sharepoint 2010. Thanks,

Reading Data using OLEDB from opened Excel File

匆匆过客 提交于 2020-01-01 19:57:07
问题 I have an excel file(Lets' say File X) with 2 sheets. In first sheet I display charts. Second I have data for the chart. In order to get data from chart, I need to process that data as we do in SQL like Group by, order by. Is there any way I can use oledb to read data from second sheet using VBA code in same excel file(file X)? Thanks!! 回答1: Here's an example of using SQL to join data from two ranges: it will work fine if the file is open (as long as it has been saved, because you need a file