oledbdataadapter

C# Typed DataSets: OleDBDataAdapter use the column names from the Typed DataSet and not ExcelSheet

风格不统一 提交于 2019-12-11 07:26:20
问题 I'm using VS 2010 with C# for a Windows Form application. I need to load my data from the Excel sheet onto a DataSet. I created the DataSet using the DataSet designer and I manually added the tables and columns (FirstTable, Column1, Column2) . Since I access the columns a lot, the code would be a lot cleaner to have a typed dataset instead of using an untyped one. When I used the OleDBDataAdapter and populated the DataTable using Fill on FirstTable , Column1 and Column2 were empty and there

Excel file - It is already opened exclusively by another user,

给你一囗甜甜゛ 提交于 2019-12-10 21:58:30
问题 I am reading the excel file using C# and below is the code which is working as expected EXCEPT that every time i run the app, I have to close the excel file otherwise I get the below error message: The Microsoft Access database engine cannot open or write to the file ''. It is already opened exclusively by another user, or you need permission to view and write its data.. my question is: is there a way i close the excel file once i am done reading? public static DataTable LoadExcelWorkbook

Export Excel File with .xlsx Extension

半城伤御伤魂 提交于 2019-12-10 17:35:24
问题 I' m trying to export xlsx file with these codes: DataTable dataTable= new DataTable(tableName); OleDbDataAdapter adapter = new OleDbDataAdapter(select, accessConnection); adapter.FillSchema(dataTable, SchemaType.Source); foreach (DataRow result in dtResult.Rows) { DataRow newRow = dataTable.NewRow(); foreach (DataRow drAssign in dtAssignment.Rows) { newRow[drAssign["Destination"].ToString()] = result[drAssign["Source"].ToString()]; } dataTable.Rows.Add(newRow); } adapter.Update(dataTable);

Quirky SELECT from Excel file via OleDbDataAdapter method (C#)

拟墨画扇 提交于 2019-12-10 10:38:02
问题 I have got an Excel file in this form : Column 1 Column 2 Column 3 data1 data2 data1 data2 data1 data2 data1 data2 data1 data2 data3 That is, the whole Column 3 is empty except for the last row. I am accessing the Excel file via OleDbDataAdapter, returning a DataTable: here's the code. query = "SELECT * FROM [" + query + "]"; objDT = new DataTable(); objCmdSQL = this.GetCommand(); objCmdSQL.CommandText = query; objSQLDad = new OleDbDataAdapter(objCmdSQL); objSQLDad.Fill(objDT); return objDT;

How do I update excel file with oleDbDataAdapter.Update(myDataSet)

孤者浪人 提交于 2019-12-08 06:40:57
问题 I keep getting an InvalidOperationException ("Update requires a valid UpdateCommand when passed DataRow collection with modified rows"). I just cant work out what's wrong with the update command. Here's the code I have so far: OleDbConnection connection; OleDbDataAdapter clientsAdapter new OleDbDataAdapter(); DataSet myDataSet = new DataSet(); public void Setup() { connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Clients.xlsx;Extended Properties=""Excel 12.0 Xml;HDR=YES"";";

How do I update excel file with oleDbDataAdapter.Update(myDataSet)

白昼怎懂夜的黑 提交于 2019-12-07 02:35:27
I keep getting an InvalidOperationException ("Update requires a valid UpdateCommand when passed DataRow collection with modified rows"). I just cant work out what's wrong with the update command. Here's the code I have so far: OleDbConnection connection; OleDbDataAdapter clientsAdapter new OleDbDataAdapter(); DataSet myDataSet = new DataSet(); public void Setup() { connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Clients.xlsx;Extended Properties=""Excel 12.0 Xml;HDR=YES"";"; connection = new OleDbConnection(connectionString); connection.Open(); // SQL clientsAdapter

Quirky SELECT from Excel file via OleDbDataAdapter method (C#)

孤者浪人 提交于 2019-12-06 05:29:05
I have got an Excel file in this form : Column 1 Column 2 Column 3 data1 data2 data1 data2 data1 data2 data1 data2 data1 data2 data3 That is, the whole Column 3 is empty except for the last row. I am accessing the Excel file via OleDbDataAdapter, returning a DataTable: here's the code. query = "SELECT * FROM [" + query + "]"; objDT = new DataTable(); objCmdSQL = this.GetCommand(); objCmdSQL.CommandText = query; objSQLDad = new OleDbDataAdapter(objCmdSQL); objSQLDad.Fill(objDT); return objDT; The point is, in this scenario my code returns a DataTable with just Column 1 and Column 2. My guess is

DataAdapter.Fill(Dataset)

落花浮王杯 提交于 2019-11-30 07:18:44
i try to get some Data from a Access Database via OleDB in a DataSet . But the DataSet is empty after the Fill() method. The same statement works and return 1 row when i trigger them manually in D*. OleDbConnection connection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Inventar.accdb"); DataSet1 DS = new DataSet1(); connection.Open(); OleDbDataAdapter DBAdapter = new OleDbDataAdapter( @"SELECT tbl_Computer.*, tbl_Besitzer.* FROM tbl_Computer INNER JOIN tbl_Besitzer ON tbl_Computer.FK_Benutzer = tbl_Besitzer.ID WHERE (((tbl_Besitzer.Vorname)='ma'));", connection);

Writing to excel using OleDb

浪尽此生 提交于 2019-11-26 23:33:54
问题 I am attempting to export rows of data from sql to excel but my Insert Command seems to fail every time. I have spent a good deal of time trying to create this but I have finally run up against the wall. The excel document is one that is generated by the IRS and we are not aloud to modify anything above row 16. Row 16 is the header row, and everything below that needs to be the data from sql. The header names all have spaces in them, and that seems to be where I am running into trouble.