How would I update a row? (Excel oledb)

The following code writes a new row (with columns that have headers):
    MyConnection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + "C:\\__\\test.xls" + ";Extended Properties='Excel 12.0 Xml;HDR=YES;'");
    MyConnection.Open();
    myCommand.Connection = MyConnection;
    string stSheetName = "Sheet1";
    string sql = "INSERT INTO [" + stSheetName + "$] (id,name) VALUES('22','a')";
How would I update row 5?
bhs67
bhs67

Modify the connection string (HRD=NO) and use the UPDATE command that I showed you in your previous thread:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/02f295e2-4069-47f2-b5c6-4f4a3480f9dc/how-do-i-write-to-specific-cells-in-excel-c-oledb?forum=csharpgeneral#06ac87e1-3315-42d4-9ced-4f534f7dc811
Or you could update a name by an id like this:
string sql = "UPDATE["+stSheetName+"$] SET name = 'www' where id = '5'";
System.Data.OleDb.OleDbCommand myCommand = new System.Data.OleDb.OleDbCommand();
System.Data.OleDb.OleDbConnection MyConnection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + "C:\\__\\test.xls" + ";Extended Properties='Excel 12.0 Xml;HDR=YES;'");
MyConnection.Open();
myCommand.Connection = MyConnection;
string stSheetName = "Sheet1";
new System.Data.OleDb.OleDbCommand("Insert into [" + stSheetName + "$] (id,name) values('1','a')", MyConnection).ExecuteNonQuery();
new System.Data.OleDb.OleDbCommand("Insert into [" + stSheetName + "$] (id,name) values('2','b')", MyConnection).ExecuteNonQuery();
new System.Data.OleDb.OleDbCommand("Insert into [" + stSheetName + "$] (id,name) values('3','c')", MyConnection).ExecuteNonQuery();
new System.Data.OleDb.OleDbCommand("Insert into [" + stSheetName + "$] (id,name) values('4','d')", MyConnection).ExecuteNonQuery();
new System.Data.OleDb.OleDbCommand("Insert into [" + stSheetName + "$] (id,name) values('5','e')", MyConnection).ExecuteNonQuery();
string sql = "UPDATE["+stSheetName+"$] SET name = 'www' where id = '5'";
myCommand.CommandText = sql;
myCommand.CommandText = sql;
myCommand.ExecuteNonQuery();
MyConnection.Close();
Hope that helps.
Please remember to mark helpful posts as answer to close your threads and then start a new thread if you have a new question. Please only ask one question per thread.

Similar Messages

  • HT204073 I had purchase one year protection plan but it is not updated till today how would I updated iPhone warranty my self

    I had purchase one year protection plan but it is not updated till today how would I updated iPhone warranty my self

    Does the iPod connect to other networks?
    Does the iPod see the network?
    Any error messages?
    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Power off and then back on the router
    - Reset network settings: Settings>General>Reset>Reset Network Settings
    - iOS: Troubleshooting Wi-Fi networks and connections
    - iOS: Recommended settings for Wi-Fi routers and access points
    - Restore from backup. See:
    iOS: How to back up
    - Restore to factory settings/new iOS device.
    - Make an appointment at the Genius Bar of an Apple store.
    Apple Retail Store - Genius Bar
    maybe this:
    iOS: Wi-Fi or Bluetooth settings grayed out or dim
    If not successful, an appointment at the Genius Bar of an Apple store is usually in order.
    Apple Retail Store - Genius Bar

  • Steps to put itunes (50 gb) on external drive and delete from imac.  How would I update my ipods and ipad from the external drive if I do this

    I am planning to put itunes library on external hard drive. My Imac is running out of room and itunes is 50+ gb of music.
    What steps do I take to do this.  Also, if I do so, how do I update my ipods and my ipad 2.  I do back up my files with time machine.  This would be a completely separate new external hard drive.  Thanks in advance for any help.

    Two ways:
    1. After transferring to the external drive create an alias to the iTunes Music folder on the external drive.  Copy the alias into your Home folder.  Rename the alias to "iTunes Music."  Delete the alias from the external drive.
    2. In the iTunes preferences click on the Advanced icon in the toolbar.  You should see a field labeled, "iTunes Media Folder Location."  Click on the Change button and select the /iTunes Music/ folder on the external drive.

  • How can i update multiple row in a advance table

    Dear all,
    hope you are well enough.
    suppose i have a table in a OA page where there are several transactions.
    i would like to add a check box in front of every row.
    when i check the transactions(rows of OA pages) and submit then one column of a table will be updated in database.
    how can i implement that.
    Please explain
    Regards,
    Mofizur

    Hi,
    Refer below code for iteration:
    OAViewObject appVO = (OAViewObject)am.findViewObject("ApprovalsWVO1");
    OARow row = (OARow)appVO.first();
    for(int i=0;i<appVO.getRowCount();i++)
    String appStatus=appVO.getCurrentRow().getAttribute("ApprovalStatus").toString();
    if(appStatus.equalsIgnoreCase("NEW"))
    newRow.setAttribute("appTrans",Boolean.FALSE);
    else
    newRow.setAttribute("appTrans",Boolean.TRUE);
    System.out.println(appStatus);
    row = (OARow)appVO.next();
    Regards
    Meher Irk

  • How can I update multiple rows?

    Hi all,
    How can I realize an Update on multiple rows? An Update statement would look like this
    UPDATE table SET value = oldvalue + x WHERE condition_field > y;My problem is: How can I execute such a statement with BC4J? I don't linke to step through the complete result set row by row.
    Thanks,
    Axel

    Get your application module object and issue this statement:
    am.getTransaction().executeCommand(<string>);This should be what you're looking for.

  • HT4623 How would you update your iPod Touch using your iPod touch?

    I want to update the software on my iPod Touch 4th Generation from my iPod Touch itself. I can't figure out how to do it, though. In the past, it has just asked me to update, but now, it doesn't do that. Anyone with any information on how to update your iPod touch software, it would be greatly appreciated if you shared your knowledge with me. Thanks so much!(:

    See:
    iOS: How to update your iPhone, iPad, or iPod touch
    If the iPad already has iOS you can go to Settings>gener>wifi update and update via wifi. Otherwise yu will have to connect to iTunes and update via iTunes.
    The current iOS is iOS 6.

  • How can I update multiple rows based on comparison of fields table1 and 2

    I create the following SQL to test what I thought was a method to update those records where the fields below match, but what ends up happening is that the update functions works the first time, and then basically updates everything to null. I am not understanding what I am doing wrong. New at this.
    UPDATE SLS_HDR B
    SET ( B.ORD_DT, B.SHIP_ADD_CD, B.INV_ADD_CD, B.LOB, B.STATUS,
    B.ORD_TYPE, B.HDR_ROUTE, B.PRICE_LIST, B.CUST_ORDER, B.REF_A, B.REF_B,
    B.ORD_REF, B.ORD_DISC, B.SREP, B.SREP2, B.PLAN_DEL_DT, B.TXTA, B.TXTB,
    B.INV_CONTACT, B.SHIP_CONTACT, B.SOLD_CONTACT, B.PAY_CONTACT, B.ORD_AMT,B.UPDATED_DT )
    = (SELECT
    A.ORD_DT, A.SHIP_ADD_CD, A.INV_ADD_CD, A.LOB, A.STATUS,
    A.ORD_TYPE, A.HDR_ROUTE, A.PRICE_LIST, A.CUST_ORDER, A.REF_A, A.REF_B,
    A.ORD_REF, A.ORD_DISC, A.SREP, A.SREP2,A.PLAN_DEL_DT, A.TXTA, A.TXTB,
    A.INV_CONTACT, A.SHIP_CONTACT, A.SOLD_CONTACT,A.PAY_CONTACT, A.ORD_AMT, SYSDATE
    FROM
    SLS_HDR_TEMP A
    WHERE
    A.FIN_COMP = B.FIN_COMP AND
    A.LOG_COMP = B.LOG_COMP AND
    A.ORD_NO = B.ORD_NO AND
    A.TRANS_DT = B.TRANS_DT AND
    A.BP_TYPE = B.BP_TYPE AND
    A.STATUS <> B.STATUS);
    Can anyone advise?
    Thank you,
    Edited by: 903292 on Dec 19, 2011 1:15 PM

    you donot have where clause in your update so un-matched rows will be updated with null values
    UPDATE SLS_HDR B
    SET ( B.ORD_DT, B.SHIP_ADD_CD, B.INV_ADD_CD, B.LOB, B.STATUS,
    B.ORD_TYPE, B.HDR_ROUTE, B.PRICE_LIST, B.CUST_ORDER, B.REF_A, B.REF_B,
    B.ORD_REF, B.ORD_DISC, B.SREP, B.SREP2, B.PLAN_DEL_DT, B.TXTA, B.TXTB,
    B.INV_CONTACT, B.SHIP_CONTACT, B.SOLD_CONTACT, B.PAY_CONTACT, B.ORD_AMT,B.UPDATED_DT )
    = (
              SELECT
              A.ORD_DT, A.SHIP_ADD_CD, A.INV_ADD_CD, A.LOB, A.STATUS,
              A.ORD_TYPE, A.HDR_ROUTE, A.PRICE_LIST, A.CUST_ORDER, A.REF_A, A.REF_B,
              A.ORD_REF, A.ORD_DISC, A.SREP, A.SREP2,A.PLAN_DEL_DT, A.TXTA, A.TXTB,
              A.INV_CONTACT, A.SHIP_CONTACT, A.SOLD_CONTACT,A.PAY_CONTACT, A.ORD_AMT, SYSDATE
              FROM
              SLS_HDR_TEMP A
              WHERE
              A.FIN_COMP = B.FIN_COMP AND
              A.LOG_COMP = B.LOG_COMP AND
              A.ORD_NO = B.ORD_NO AND
              A.TRANS_DT = B.TRANS_DT AND
              A.BP_TYPE = B.BP_TYPE AND
              A.STATUS= B.STATUS
    WHERE EXISTS
         select null from SLS_HDR_TEMP A
         WHERE
         A.FIN_COMP = B.FIN_COMP AND
         A.LOG_COMP = B.LOG_COMP AND
         A.ORD_NO = B.ORD_NO AND
         A.TRANS_DT = B.TRANS_DT AND
         A.BP_TYPE = B.BP_TYPE AND
         A.STATUS= B.STATUS
    )OR using Merge
    Merge into SLS_HDR B
    using SLS_HDR_TEMP A
    on (A.FIN_COMP = B.FIN_COMP AND
    A.LOG_COMP = B.LOG_COMP AND
    A.ORD_NO = B.ORD_NO AND
    A.TRANS_DT = B.TRANS_DT AND
    A.BP_TYPE = B.BP_TYPE AND
    A.STATUS= B.STATUS)
    when matched then update set (B.ORD_DT, B.SHIP_ADD_CD, B.INV_ADD_CD, B.LOB, B.STATUS,
    B.ORD_TYPE, B.HDR_ROUTE, B.PRICE_LIST, B.CUST_ORDER, B.REF_A, B.REF_B,
    B.ORD_REF, B.ORD_DISC, B.SREP, B.SREP2, B.PLAN_DEL_DT, B.TXTA, B.TXTB,
    B.INV_CONTACT, B.SHIP_CONTACT, B.SOLD_CONTACT, B.PAY_CONTACT, B.ORD_AMT,B.UPDATED_DT ) = (A.ORD_DT, A.SHIP_ADD_CD, A.INV_ADD_CD, A.LOB, A.STATUS,
    A.ORD_TYPE, A.HDR_ROUTE, A.PRICE_LIST, A.CUST_ORDER, A.REF_A, A.REF_B,
    A.ORD_REF, A.ORD_DISC, A.SREP, A.SREP2,A.PLAN_DEL_DT, A.TXTA, A.TXTB,
    A.INV_CONTACT, A.SHIP_CONTACT, A.SOLD_CONTACT,A.PAY_CONTACT, A.ORD_AMT, SYSDATE)HTH...
    Thanks

  • How can I update multiple rows in table using a single form button and checkboxes

    I have a project where the visitors can select multiple productos and once the click on the PURCHAS button it updates the selected records.

    You have not mentioned the programming language that you are using, but here's a link that could help you if you are using ASP.
    http://csharpdotnetfreak.blogspot.com/2009/05/edit-multiple-records-gridview-checkbox.html
    Also, have a look at this discussion thread
    http://forums.asp.net/t/1470882.aspx

  • "How would I add the rows of a 640 x 240 2D array together? I mean , the elements of row 1 to the element of row 2 and so on. I want to end up with a 1 d array of 640 elements in which each element is the sum of the other 240 elements in the rows."

    "For explaination , like this
    1 1 1 1 1 1 1 ....... to 640
    +2 2 2 2 2 2 2 .......
    +3 3 3 3 3 3 3 .......
    =6 6 6 6 6 6 6 ....... this is the final 1D array of summed elements."
    Appreciate the sample VI's but I can't open them ( I have Labview 5.01 )

    Here is Mikael solution, expanded to include rows and ready to use as a subVI. Now all is needed is the polymorphic version
    www.vartortech.com
    Attachments:
    Sum_rows_or_colums.vi ‏25 KB

  • How would I update my Firefox downward from v11 back to v10

    I have been using Firefox v11 but found out from Norton that Norton 360 v6 is compatible with Firefox v10. How do I downgrade back to v10?

    Visit [http://www.mozilla.org/en-US/firefox/fx/ http://www.mozilla.org/en-US/firefox/fx/], then download a fresh version of Firefox. Then, read [[Uninstalling Firefox|Uninstalling Firefox]] (make sure you KEEP all your personal data).
    Then just install the Firefox 10.0.2 you downloaded earlier.

  • How to update Ztable from Excel file and how to check conditions ,

    HI this uday,
    pls help me how can i update Ztable from Excel file and how to check conditions .
    regards
    uday
    Moderator message: please (re)search yourself before asking.
    Edited by: Thomas Zloch on Jul 13, 2010 12:00 PM

    Hi
    Use Fm : ALSM_EXCEL_TO_INTERNAL_TABLE.
    L_INTERN : internal table with your fields .
    make sure that the fields in the Excel should be formatted (as numeric , characher ) depending upon the data types .
    LOOP AT L_INTERN INTO WA_LINTERN .
            MOVE WA_LINTERN-COL TO L_INDEX.
            ASSIGN COMPONENT  L_INDEX OF STRUCTURE WA_INREC TO <FS> .
            IF SY-SUBRC = 0.
              MOVE WA_LINTERN-VALUE TO <FS>.
            ENDIF.
            AT END OF  ROW .                                    "#EC *
              APPEND WA_INREC TO IT_DATA.  "
              CLEAR WA_INREC.
            ENDAT.
         ENDLOOP.
    Regards
    Swapnil

  • Update multiple rows based on two columns in same row

    I have a 1000 rows in a table I would like to update with a unique value. This unique value is a cocatenation of two columns in teh same row.
    Each row has a (i) date and a (ii) time and a (iii) date_time column. I would like to update the date_time (iii) column with a cocatenation of the (i) date and (ii) time columns.
    I know how I would update a single row but how can I update multiple rows with a cocatenation of each of the two columns - i.e put a different value into the date_time column for each row?

    this?
    update table tab_name
    set date_time =date||time
    where your_condition

  • BC4J datagrid to update multiple rows

    Hi,
    How do we update multiple rows at a time in a BC4J JSP with Struts. I intend to have a datagrid control on a JSP so that users may update multiple rows at a time and click 'Update' once.
    There is a possible (workaround) solution using struts nested tags but one would lose the benefits of JBO tags on using struts tags (e.g Calendar control would not be visible for Date input).
    Any implementation suggestions?
    Regards,
    Ashish

    Does the database only contain data where there are events on a given 15-minute time slot?

  • Updating multiple rows in a table in ADF

    Hi
    How do we update multiple rows in a table.
    Onclicking a update button the changed rows must be updated.

    Hi Prince,
    currently I am selecting one row from the table and rendering a region at the top of the table and capturing the user entered data with the following code:
    ViewObjectVOImpl vo = getViewObjectVO1();
    Row CurrentRow = vo.getCurrentRow();
    //After this I perform the checks like user entered value is not null or check input as per business logic.
    if(CurrentRow.getAttribute("attributeName") ==null){
    //Add what message you want to display
    //Add other business logic.
    After making all the checks, i commit it.
    getOADBTransaction().commit();
    Now in my new page I am capturing the user input in the table itself like an excel sheet. Suppose there are ten rows in my advanced table on my page, and each row has one editable field. I have one save button at the bottom of the table.
    Now on clicking the save button I have to capture the user input, check whether there is any null value and if all the entered data is correct then only I should commit it.
    Can you please let me know how we can accomplish that.
    Regards
    Hawker

  • Update multiple rows involving spatial data

    Hi,
    i have 2 table, that are
    temp
    store_id
    store_state
    geom mdsys.sdo_geometry
    us_states
    state
    geom mdsys.sdo_geometry
    i have indexed both table with spatial index.
    If i wanna find state that temp.geom is inside us_states.geom using
    SQL> select state from us_states, temp
    where sdo_inside(temp.geom, us_states.geom) = 'TRUE';
    it's work
    but if i wanna update temp.store_state using
    SQL> update temp set store_state = (select state from us_states
    where sdo_inside(temp.geom, us_states.geom) = 'TRUE');
    it gives this error
    update temp set store_state = (select state from us_states where sdo_inside(temp.geom, us_states.geom) = 'TRUE')
    ERROR at line 1:
    ORA-13226: interface not supported without a spatial index
    ORA-06512: at "MDSYS.MD", line 1723
    ORA-06512: at "MDSYS.MDERR", line 8
    ORA-06512: at "MDSYS.SDO_3GL", line 62
    ORA-06512: at "MDSYS.SDO_3GL", line 192
    any idea how can i update multiple rows that involving spatial data?
    Thanks
    Hadi

    Hadi,
    There are a number of things wrong with the second item. First up you most likely will return more than one row, which is not allowed as the = expects only one item.
    Here is what I would use, which will update everything that meets the requirements, and ignore the rest:
    UPDATE (
    SELECT /*+ bypass_ujvc */
    state, store_id, store_state
    FROM temp, us_states
    WHERE sdo_inside(temp.geom, us_states.geom) = 'TRUE')
    SET store_state = state;
    With the /*+ bypass_ujvc */ you're telling the db to not worry about requiring a "unique join view condition" -- which roughly mean "trust me, my rows are key preserved." This is important since there is really no "hard" key-based relationship to tie the two together.
    However, unless you really think there are stores that border on two states, this will run much quicker with an anyinteract comparison.
    Bryan

Maybe you are looking for

  • X1 Carbon Gen3 (2015) Chassis constantly clicks in and out of position

    It's been 1 week since I received my first Lenovo Laptop - X1 Carbon Gen3 and I'm very pleased with it so far. Since the beginning I noticed a 'clicking' sound produced when resting my palms on the keyboard to type, but couldn't figured out what it w

  • Verizon now forcing new contracts instead of month to month

    My FIOS bundle expired in March. I understood both from online statements and from talking with Verizon support that my services would continue on a month to month basis. I was happy with this while I look at whether I will continue with FIOS, purcha

  • Design View Not displaying the page

    Recently I asked the same question here but I think I did not explain myself correctly. I have hunted for answers but not found any so I am asking again with images this time. I have had this site written for me and I know it was written in DW. They

  • Localization of text objects in Crystal Report RPT file

    Dear all, Does anyone know how support multiple locale text (English and French) in one single Crystal Report RPT file.  Is there a way to parameterize  text objects (including tiles, axis,  of chart) in the Crystal Report RPT files to use some sort

  • Batch capturing free run timecode.

    Hi, I have just been through and logged 3 hour tape which was recorded on free run timecode. I have just tried to batch capture it all and it isnt working because of the timecode discontinuity. Is their a way I can override this? Any help would be ap