oledb

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

人走茶凉 提交于 2019-11-27 20:27:08
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. ended up using this: using (OleDbConnection conn = new OleDbConnection(connString)) { conn.Open(); dtSchema = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" }); Sheet1= dtSchema.Rows[0].Field<string>(

How can I export data to an Excel file

≯℡__Kan透↙ 提交于 2019-11-27 20:11:21
I have an Excel file with data in it. I want to write some specific rows of it to another Excel file that I created by code. By the way I have the indexes of these rows in a list. How can i do that? Yahia MS provides the OpenXML SDK V 2.5 - see https://msdn.microsoft.com/en-us/library/bb448854(v=office.15).aspx This can read+write MS Office files (including Excel)... Another option see http://www.codeproject.com/KB/office/OpenXML.aspx IF you need more like rendering, formulas etc. then there are different commercial libraries like Aspose and Flexcel... private void button1_Click(object sender,

“The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine”…DNN

被刻印的时光 ゝ 提交于 2019-11-27 18:32:23
问题 I'm trying to get a new DotNetNuke site up and running on our 64-bit server, and I'm encountering the following error message: "The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine" I know from experience that you run into this when you target a 64-bit assembly on a 64-bit machine (there is no 64 bit OLE-DB provider currently). In that case, I simply target the x86 in Visual Studio and everything works fine. But in this case, the site uses dynamic compilation, so

Dapper & MS Access - Read works, Write doesn't

南笙酒味 提交于 2019-11-27 18:09:09
问题 Let's start by getting this out of the way: I'm stuck using an MS Access DB and I can't change it. This works fine: using (OleDbConnection conn = ConnectionHelper.GetConnection()) { conn.Open(); var results = conn.Query<string>( "select FirstName from Students where LastName = @lastName", new { lastName= "Smith" } ); conn.Close(); } This works fine: using (OleDbConnection conn = ConnectionHelper.GetConnection()) { OleDbCommand cmd = new OleDbCommand( "update Students set FirstName =

C#/ASP.NET Oledb - MS Excel read “Unspecified error”

一世执手 提交于 2019-11-27 16:51:15
问题 We have a C#/ASP.NET (2.0) application running on IIS 6 on Windows Server 2003 Enterprise Edition. This application reads Excel files using OleDb, but there are instances when we get an "Unspecified Error" exception thrown from within the application. The file is stored in the temporary directory by our file upload code before opening. Since we have anonymous access enabled in IIS and since we also use impersonation in web.config, the folder C:\Windows\Temp\ has the proper permissions for the

Ms Access - System resource exceeded inserting rows

半世苍凉 提交于 2019-11-27 16:27:25
I want to insert 1500 rows to Ms access database from vb.net datagridview. Inserting up to 400 rows no issue, but above 400 rows its showing error - System resource exceeded. Im using below code. The error is highlighting to: readinputs = dbup.ExecuteReader() and sometimes .ExecuteNonQuery() Dim Dbcon As New OleDbConnection(connStr) Dbcon.Open() Dim query As String Dim dbup As New OleDbCommand Dim readinputs As OleDbDataReader For x As Integer = 0 To IncomingMailDGV.Rows.Count - 1 Dim received As String = IncomingMailDGV.Rows(x).Cells(0).Value Dim subject As String = IncomingMailDGV.Rows(x)

Access 2007 - INSERT and instant SELECT doesn't retrieve the inserted data

依然范特西╮ 提交于 2019-11-27 16:22:26
I'm inserting a few rows in a table via OleDB, and select instantly the inserted row. I can't retrieve the row in this way, i have to wait for approx. 3-5 seconds. And then the inserted row appears in the table. I observed this behavior in the database itself, i inserted the row via OleDB and watched the opened table in Access. The row appeared 3-5 seconds later in the table. Does Access buffer rows? Do i have to send a flush or commit, etc. via OleDB ? Any suggestions would be very helpful. (Please don't ask why I don't solve this through my business logic or other ways....) I did some

OleDbCommandBuilder creates SQL statements that result in “syntax error”

冷暖自知 提交于 2019-11-27 16:21:27
Can someone please explain why, when I click the "Commit" button, I get the error Syntax error in INSERT INTO statement. Here's the code. Public Class Form3 Dim inc As Integer Dim MaxRows As Integer Dim con As New OleDb.OleDbConnection Dim ds As New DataSet Dim da As OleDb.OleDbDataAdapter Dim sql As String Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = D:\TA_Officers.mdb" con.Open() sql = "SELECT * from TA_OFFICER" da = New OleDb.OleDbDataAdapter(sql, con) da.Fill(ds,

Parameterized query for inserting values

混江龙づ霸主 提交于 2019-11-27 15:23:49
I was trying to insert values into an Access database using a parameterized query: private void button1_Click(object sender, EventArgs e) { if (validationcontrol()) { MessageBox.Show(cmbjobcode.SelectedValue.ToString()); OleDbConnection oleDbConnection1 = new System.Data.OleDb.OleDbConnection(connString); oleDbConnection1.Open(); OleDbCommand oleDbCommand1 = new System.Data.OleDb.OleDbCommand("INSERT INTO quotationmastertable (quotationcode ,jobcode , jobpk , sillabordercharges , battabordercharges , driverpayment , rent , extra , total , discount , remark ,amount ) Values (?,?,?,?,?,?,?,?,?,?

Programmatically finding an Excel file's Excel version

混江龙づ霸主 提交于 2019-11-27 14:55:05
I'm using an OleDbConnection to connect to a spreadsheet from a C# program. One of the parameters in the connection string is the Excel version. "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Book1.xls;Extended Properties=" Excel 8.0 ;HDR=YES" Given the path of an Excel file how can I find out which Excel format version it uses? Thanks in advance, T. Download OLE File Property Reader . Register dsofile.dll with regsvr32 and add it as a reference in your application. The following code will output the type of Excel file. It will not work on xlsx/docx since those are not OLE compunds object