oledbcommand

Selecting the Excel sheet used range using OLEDB Connection

自闭症网瘾萝莉.ら 提交于 2019-12-08 12:25:16
问题 Is there any way to select the Excel sheet used range via OLEDB Command object? Because I have an Excel file that has 400 rows, but when I delete 200 rows and try to select the sheet again, it's selecting up to 400 rows again instead of selecting the 200 rows. This is the code which I've written to select the sheet: oledbConn = new OleDbConnection(connectionString); oledbCmd = new OleDbCommand("select * from [Sheet1$]", oledbConn); oledbConn.Open(); oledbDr = oledbCmd.ExecuteReader(); while

Importing from Excel - Header is not on row 1

家住魔仙堡 提交于 2019-12-07 18:50:17
问题 Is there some simple way I am missing to import an Excel worksheet into a datatable using an OleDBConnection and change what row the header is located on? I have HDR=YES in my connection string and that works great when header is on row 1 but the header is actually going to need to be on row 3. I am using the following CommandText: SELECT [headercol1name], [headercol2name], [headercol3name] FROM [sheetname] 回答1: You can specify a range: How can I programmatically import Excel data into an

Importing from Excel - Header is not on row 1

徘徊边缘 提交于 2019-12-06 08:13:58
Is there some simple way I am missing to import an Excel worksheet into a datatable using an OleDBConnection and change what row the header is located on? I have HDR=YES in my connection string and that works great when header is on row 1 but the header is actually going to need to be on row 3. I am using the following CommandText: SELECT [headercol1name], [headercol2name], [headercol3name] FROM [sheetname] Fionnuala You can specify a range: How can I programmatically import Excel data into an Access table? "SELECT * FROM [Sheet1$A3:G65536]" will only return records for used range, though I

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

Update a row in oracle using OLEDB command(SSIS)

自古美人都是妖i 提交于 2019-12-06 03:08:31
问题 I am trying to update some rows in an oracle Database, using an OLEDB Command but whenever i try specifying the Sql Command this is what i get An OLEDB record is available. Source: "OraOLEDB" Hresult:0x80040E51 Description: "Provider cannot derive parameter information and SetParameterInfo has not been called." I have tried using "Native OLE DB\Oracle Provider for OLE DB" provider and i tried changing to "Native OLE DB\Microsoft OLE BD Provider for Oracle" provider but i get the same error,

Update a row in oracle using OLEDB command(SSIS)

血红的双手。 提交于 2019-12-04 08:39:55
I am trying to update some rows in an oracle Database, using an OLEDB Command but whenever i try specifying the Sql Command this is what i get An OLEDB record is available. Source: "OraOLEDB" Hresult:0x80040E51 Description: "Provider cannot derive parameter information and SetParameterInfo has not been called." I have tried using "Native OLE DB\Oracle Provider for OLE DB" provider and i tried changing to "Native OLE DB\Microsoft OLE BD Provider for Oracle" provider but i get the same error, please help, I am using ssis 2008 Here is the setup : The Connection Manager is as below When i test it,

Issue in updating MS Access records using oledbcommand.executeNonQuery(), result not updating

China☆狼群 提交于 2019-12-02 12:18:02
问题 I am posting a query first time here, So, Please ignore my formatting. I am trying to update my .accdb file using update command, but result of oledbcommand.executeNonQuery() is 0 hence result is not updating in the database. Though I am receiving no errors. Here is what I am doing. string vsql = string.Format("UPDATE DefTask_List SET [Action]=@Action WHERE [SNo]=@SNo"); vcom.Parameters.AddWithValue("@SNo", row.Cells[0].Value.ToString()); vcom.Parameters.AddWithValue("@Action", comboBox1.Text

“Parameter ?_1 has no default value” error when ExecuteReader

▼魔方 西西 提交于 2019-12-02 10:14:28
Having problem with the code below in a web service. Have searched for a solution but nothing that I have seen seems different to what I am doing below. NB: The string variable 'AccountNo' is a passed into a function which includes the code below. The error is generated on the last line of code - ExecuteReader. Dim sConnString As String Dim rdr As OleDbDataReader Dim orderPaid As Decimal Dim fbeused As Decimal sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='c:\orders.mdb'" Dim conn As New OleDbConnection(sConnString) Dim sb As New StringBuilder sb.Append("SELECT DISTINCTROW

OleDB update command not changing data

ε祈祈猫儿з 提交于 2019-12-02 08:54:40
问题 I'm using Microsoft Access file as database. I have no problem with SELECT and INSERT queries but when I try to UPDATE , record in database does not change. Below is the code I use to run update. There are no exceptions or errors in debug log. cnn = new OleDbConnection(connetionString); OleDbCommand command = new OleDbCommand("UPDATE [Wpisy] SET [wpis]=@wpis, [id_kat]=@id_kat, [tytul]=@tytul WHERE [ID]=@id_wpis" , cnn); command.Parameters.Add(new OleDbParameter("@wpis", tresc_wpisu.Text));

Update specific cell of excel file using oledb

好久不见. 提交于 2019-12-02 07:30:43
I want to update the specific cell of the excel file using oledb. Say I7 cell, for some reason always I1 is getting updated. Can anyone tell me what's wrong with this code? OleDbConnection oledbConn = new OleDbConnection(connString); oledbConn.Open(); // I want to set the value of I7 cell to 22, for some reason value is I1 is getting updated :( OleDbCommand cmd = new OleDbCommand("UPDATE [" + sheetName + "$I7:I7] SET F1=22", oledbConn); int result = cmd.ExecuteNonQuery(); Console.WriteLine(result); oledbConn.Close(); This may purely be an issue with the cell address scheme you're using. Try $I