How to update record from datagridview

hi every one 
am new in .net am developing an inventory system for learning.
i successfully develop a purchase  form where user can put record for parching invoice.
as
and for save record am using flowing code.
Private Sub btn_Save_Click(sender As Object, e As EventArgs) Handles btn_Save.Click
        Dim connectionStringdgv As String = "Data Source= ABDULLAH-PC;Initial Catalog=Erpdb;Persist Security Info=True;User ID=jabbar;Password=abc123"
        Dim connection As New SqlClient.SqlConnection(connectionStringdgv)
        Dim adaptor As New SqlClient.SqlDataAdapter
        Dim adaptor1 As New SqlClient.SqlDataAdapter
        Dim dataset As New DataSet()
        Dim datasetmax As New DataSet()
        Dim adaptor3 As New SqlClient.SqlDataAdapter
        Dim adaptormax As New SqlClient.SqlDataAdapter
        Dim dataset3 As New DataSet()
        Dim dataset1 As New DataSet()
        Dim cmdinsert As New SqlClient.SqlCommand
        Dim cmdinsert1 As New SqlClient.SqlCommand
        Dim cmduppurtable As New SqlClient.SqlCommand
        Dim cmdupdrcrtable As New SqlClient.SqlCommand
        Dim cmdinsert2 As New SqlClient.SqlCommand
        Dim Cmd As New SqlClient.SqlCommand
        Dim Commandmax As New SqlClient.SqlCommand
        connection.Open()
        cmdinsert1.Connection = connection
        cmdinsert1.CommandText = "INSERT INTO purtrans(date,amount,paid,discount,[bill no],taxvalue,ac,tax)" _
            & "VALUES ('" & DateTimePicker2.Text & "','" & GAmt.Text & "','" & amtpaid.Text & "','" & Tdis.Text & "','" & invo.Text &
"','" & ttax.Text & "','" & txtCode.Text & "','" & tv.Text & "')"
        cmdinsert1.ExecuteNonQuery()
        'find last id'
        Commandmax.Connection = connection
        Commandmax.CommandText = "SELECT date,MAX(sr) FROM purtrans GROUP BY date"
        Commandmax.ExecuteNonQuery()
        adaptormax.SelectCommand = Commandmax
        Dim maxtable As New DataTable
        adaptormax.SelectCommand = Commandmax
        adaptormax.Fill(maxtable)
        If maxtable.Rows.Count > 0 Then
            SrTextBox.Text = maxtable.Select.Last.Item(1)
        End If
        If connection.State = ConnectionState.Open Then
            connection.Close()
        End If
        connection.Close()
        Dim n, m As Integer
        n = Me.dgv.Rows.Count - 1
        For m = 0 To n - 1
            Dim cd As String = "insert Into amountdrcr(todate,ac,party1,amount,purtransid,qty,rate,billno,disc,tax,weight,sp,drcr) VALUES (@todate,@ac,@Party1,@amount,@purtransid,@qty,@rate,@billno,@disc,@tax,@Weight,'Purchase','Dr')"
            Cmd = New SqlClient.SqlCommand(cd)
            Cmd.Connection = connection
            Cmd.Parameters.AddWithValue("todate", DateTimePicker2.Text)
            Cmd.Parameters.AddWithValue("ac", dgv.Rows(m).Cells("itemcode").Value)
            Cmd.Parameters.AddWithValue("party1", cmbname.Text)
            Cmd.Parameters.AddWithValue("amount", dgv.Rows(m).Cells("Amount").Value)
            Cmd.Parameters.AddWithValue("purtransid", SrTextBox.Text)
            Cmd.Parameters.AddWithValue("Qty", dgv.Rows(m).Cells("Qty").Value)
            Cmd.Parameters.AddWithValue("Rate", dgv.Rows(m).Cells("Rate").Value)
            Cmd.Parameters.AddWithValue("BILLNO", invo.Text)
            Cmd.Parameters.AddWithValue("Disc", dgv.Rows(m).Cells("Disc").Value)
            Cmd.Parameters.AddWithValue("tax", txtPerVat.Text)
            Cmd.Parameters.AddWithValue("Weight", dgv.Rows(m).Cells("Weight").Value)
            connection.Open()
            Cmd.ExecuteNonQuery()
            connection.Close()
        Next
        MsgBox("Your Record save Sucssfully", vbOKOnly, "AANO TECH")
        'posting a credit voucher for supplier'
        If Balance.Text > 0 Then
            Dim cd2 As String = "insert Into amountdrcr(todate,ac,party1,amount,purtransid,billno,sp,drcr) VALUES (@todate,@ac,@Party1,@amount,@purtransid,@Billno,'Purchase','Cr')"
            cmdinsert2 = New SqlClient.SqlCommand(cd2)
            cmdinsert2.Connection = connection
            cmdinsert2.Parameters.AddWithValue("todate", DateTimePicker2.Text)
            cmdinsert2.Parameters.AddWithValue("ac", txtCode.Text)
            cmdinsert2.Parameters.AddWithValue("party1", cmbname.Text)
            cmdinsert2.Parameters.AddWithValue("amount", Balance.Text)
            cmdinsert2.Parameters.AddWithValue("purtransid", SrTextBox.Text)
            cmdinsert2.Parameters.AddWithValue("billno", invo.Text)
            connection.Open()
            cmdinsert2.ExecuteNonQuery()
            connection.Close()
            dgv.Rows.Clear()
            btn_Save.Enabled = False
            invo.Text = ""
            txtCode.Text = ""
            TAmt.Text = ""
            GAmt.Text = ""
            Tdis.Text = ""
            Balance.Text = ""
            ttax.Text = ""
            amtpaid.Text = ""
            txtAddress.Text = ""
            txtPhone.Text = ""
            cmbname.Text = ""
            btnAdd.Enabled = False
            txtQty.Text = ""
            Wk.Text = ""
            txtRate.Text = ""
            txtRate.Text = ""
            txtPerDisc.Text = ""
            txtPerVat.Text = ""
            cmbItemCode.Text = ""
            cmbitemname.Text = ""
            invo.Focus()
        Else
            dgv.Rows.Clear()
            btn_Save.Enabled = False
            invo.Text = ""
            txtCode.Text = ""
            TAmt.Text = ""
            GAmt.Text = ""
            Tdis.Text = ""
            Balance.Text = ""
            ttax.Text = ""
            amtpaid.Text = ""
            txtAddress.Text = ""
            txtPhone.Text = ""
            cmbname.Text = ""
            txtQty.Text = ""
            Wk.Text = ""
            txtRate.Text = ""
            txtRate.Text = ""
            txtPerDisc.Text = ""
            txtPerVat.Text = ""
            cmbItemCode.Text = ""
            cmbitemname.Text = ""
            btnAdd.Enabled = False
            invo.Focus()
        End If
what is the easiest way for editing record
please guide me thanks
 

Hi ABDULLAH,
>> what is the easiest way for editing record
What do you mean by “editing record” ? Do you mean that you want to update the record according the textboxes in the form? If so, I am afraid that there is no better way, you need to use the ado.net and the update command to achieve that like you insert
new records. If you want to modify the record in the datagridview directly, I think you could bind the dataset to the datagridview, and then modify the record in the datagridview, and then save the changes to the database. The link below might be useful to
you:
# DataGridview Update
https://social.msdn.microsoft.com/Forums/en-US/5980181e-f666-4f0a-ab50-c4ebecf96f02/datagridview-update-?forum=Vsexpressvb
Best Regards,
Edward
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.

Similar Messages

  • How to update Records from Internal table to u2018Zu2019 table?

    Hi Friends,
    How to update Records from Internal table to u2018Zu2019 table.
    I have records in Internal table , that records want to update on u2018Zmarau2019 Table.
    ( my internal table & u2018 Zu2019 table structures are same.)
    Thanking you.
    Regards,
    Subash

    Hi,
    loop at internal table.
    modify <Z- table > from values < internal table Workarea>.
    if sy-subrc = 0.
      COMMIT work.
    else.
      ROLLBACK waork.
    endif.
    endloop.
    or
    UPDATE <Z- table > from table < internal table Workarea>.
    if sy-subrc = 0.
      COMMIT work.
    else.
      ROLLBACK waork.
    endif.
    Prabhudas

  • Getting the un updated records from receiver JDBC

    Hi Friends,
         I am doing the Proxy - jdbc integration. Consider my proxy sends 10 records to JDBC to update. Consider bcoz of some reason the jdbc updates only 8 records i need to get the 2 records back to Proxy which is not updated in the DB.
    Should i need to use the Proxy and JDBC channel as syn or seperate integration should be built. I have seen some documents, that we can get the count of the updated records from jdbc receiver, but i dont need the count i need the record which is not been updated.
    How can i do it. please give ur inputs.
    thanks
    Prem

    Unless  you are using SP on JDBC side and explicitly build a record set to send back the data it might not be possible. I am not sure if a custom record set could be returned in JDBC sync receive adapter. You can realize this by updating some other table on JDBC side and then polling that table to update ecc back.
    VJ

  • HT1338 how to update software from 10.5 to 10.7?

    how to update software from 10.5 to 10.7?

    You need to buy a Mac OS X 10.6 DVD from the online Apple Store, and phone them and order a download code for Mac OS X 10.7. Mac OS X 10.7 requires a Mac with a Core 2 Duo(not Core Duo) or better CPU and at least 2GB of RAM.
    (77981)

  • Deleting/Updating records from an object table in PL/SQL

    Hello All,
    VER:
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE     11.2.0.3.0     Production
    TNS for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    I have created an object and inserted records in it. Is there any way we can delete/update records from it. I do not want to delete based on iteration like delete.collection but I would like to know if we can delete directly from obj like delete from table...
    CREATE OR REPLACE TYPE test_type AS OBJECT
    col1 number,
    col2 varchar2(100)
    CREATE OR REPLACE TYPE tab_type is table of test_type;
    DECLARE
    test_tab tab_type;
    l_cnt NUMBER;
    BEGIN
    select test_type(col1,col2) bulk collect
    into test_tab from (select 1 as col1,'test1' as col2 from dual
                        union all
                        select 2,'test2' from dual);
    IF test_tab.count>0
    THEN
    DELETE FROM TABLE(CAST(test_tab as tab_type)) a
    where a.col1=1;
    END IF;
    l_cnt := test_tab.count;
    END;Thx
    Shank.

    SB,
    I have a scenario wherein I insert few records into a collection table. I'm gonna filter few records from collection table based on the filter.
    I want to delete the records that didn't match the filter. Right now, I'm inserting the records into a physical table and deleting from there. I do no want to use a physical table. Trying to avoid it.
    Would like to delete from collection itself.
    DELETE FROM TABLE(CAST(lv_attr_filter_tab as EDMS_CSPP_DISC_REQ_TAB_TYPE))
                                 WHERE NOT EXISTS (SELECT 1
                                       FROM edms_disc_lines_stg edls
                                       WHERE edls.req_id = edrg.request_id
                                          AND edls.disc_line_id = edrg.discount_id
                                          AND UPPER(edls.disc_status) IN ('ACTIVE');

  • How can i record from radio to mp3 format?

    How can i record from radio to mp3 format?
    because i want to record a radio program, and save it, how can i do it?

    If you can, the instructions will be in the user manual - iPod Manuals

  • How to update Records of SAP table from .CSV file

    Hi,
    I have written a code which takes a data from (,) delimited CSV file and adds it into the Internal table.
    Now I want to update the all fields in SAP table with the Internal table.
    I want to use Update statement.
    Update <table Name> SET <field needs to update> WHERE connditon.
    I don't want to iterate through thousand on record in sap table to check the where condition.
    Could you please tell me how to do it.

    Hi. I thing you will not workaround the iterating of the internal table.
    You can pre-load all the records into another internal table
    check lt_csv[] is not initial. " important, otherwise next select would read all records of the table
    select .... into lt_dbitab for all entries in lt_csv where key-fieds = lt_csv-key_fields...
    check sy-subrc eq 0 and lt_dbitab[] is not initial.
    then do in-memory update of the it_dbitab
    loop at it_dbitab assign <fs>.
      read table lt_csv assign <fs_csv> with key ... " lt_csv should be sorted table with key, or you should try to use binary search
      if sy-subrc eq 0.
        ...change required lt_dbitab fields: <fs>-comp = <fs_csv>-comp...
      endif.
    endloop.
    ant then you can do mass-update
    update dbtab from table lt_dbitab.
    From performance view, this solution should be much faster than iterating lt_csv directly and updating every single database record
    Br
    Bohuslav

  • How to update record in Table control

    Dear Friends,
      I have table control that has space for 10 records but i need to update 15 record from the flat file which is getting into the table how can i do this.
    Regards,
    MAHENDRA.

    Hi,
    you record for an item and then click on page down and save it.use the loop on this bdc to populate the the bdc table no need to do manually.
    LOOP AT  l_i_dettab_item INTO l_wa_dettab_item..
          l_cursor = l_cursor + 1.
          IF l_cursor GT 1.
            PERFORM bdc_field       USING 'BDC_OKCODE'
                                   '=P+'.
          ENDIF.
          PERFORM cursor_pos_notation    USING 'V_EAN_DET001- GTIN_VARIANT_TYP'
                                                  l_cursor
                                        CHANGING  l_cursor_notation.
          PERFORM cursor_pos_notation    USING 'V_EAN_DET001-VTWEG'
                                                  l_cursor
                                        CHANGING  l_cursor_notation.
          PERFORM bdc_field       USING l_cursor_notation
                                        l_wa_dettab_item-vtweg.
          PERFORM cursor_pos_notation    USING 'V_EAN_DET001-DATEFROM'
                                                  l_cursor
                                        CHANGING  l_cursor_notation.
             PERFORM bdc_field       USING l_cursor_notation
                                        l_v_date.
          PERFORM bdc_field       USING 'BDC_CURSOR'
                                        l_cursor_notation.
          PERFORM bdc_field       USING 'BDC_OKCODE'
                                        '=SAVE'.
        ENDLOOP.
    Here my ok code for page down is =P+  so i am looping on the table control data and then populating the bdc table after this i will populate the remaing info required for the call transaction and refresh bdcdata.
    thats it no need to do recording 1000 times.
    now if u do like this it doesn't depend on the number of records on table control.
    it will take all the records.
    Reward if useful.
    Regards,
    sasi
    Regards,
    sasi

  • Error : update record from wizard

    i m trying to build 3 page registration for my website using Developer Toolbox. First i insert records using Insert record from wizard and in the next step i want to update the same record(in the first step i m having upload and resize image). how to get the last insert id and pass the id to URL so that i can retrive the last insert id from the URL and update the same record... somebody please help me....
    Thanks
    Priya_Baer

    Please have a look at the thread I WANT THE RESULT PAGE OF MY INSERT FORM TO BE AN UPDATE FORM OF THE JUST INSERTED DATA where a solution (based on attaching the "last insert id" value to a Session Variable) has recently been provided.
    Cheers,
    Günter

  • Need help: updating records from a node to another node.

    Hi Gurus,
    I guess most of you would be laughing at me but I'll not from Java background but.
    scenario:
    I have a node (eg. Node A) containing some records, say...with keys A,B,C,D,E.
    I also having anothe node (eg Node B) containing the update records of some of the Keys, eg. A,D,E
    How do I update node A with the updated values of node B.
    a ABAP representation would be:
    LOOP AT NODE_B.
      LOOP AT NODE_A.
        IF NODE_A-KEY = NODE_B-KEY.
          MOVE-CORRESPONDING NODE_B to NODE_A.
          MODIFY NODE_A.
        ENDIF.
      ENDLOOP.
    ENDLOOP.
    thanks.

    Hi Jansen,
    Are you using model node or value? If it is model node you need store in Node B just reference to model class from Node B. If it is value node then you can store keys of elements from Node A moved to Node B in some java Map implementation.
    Best regards, Maksim Rashchynski.

  • How to update attributes from OIM to AD in case of LDAPSync

    Hi All,
    In our scenario, we have LDAPSync configured for OIM AD Integration. OIM version is OIM 11gR2 PS1 (11.1.2.1.0.0)
    It is working fine and On user creation in OIM ,RealTime user creation under specified container in AD is happening.It is SSL enabled,so password is also getting updated from OIM to AD.
    But we have following conflicting scenario --
    -   As per our requirement we have to generate random password for User in OIM. For that we have PostProcess event handler implemented in OIM.
    - We have tested LDAPSync by creating user manually through OIM console. While creating user manually, we have provided value for password attribute along with other attributes.
        So, password attribute in AD will get updated for User along with all other attributes values mapped for AD from OIM.
    - But, in our scenario random password is generated for User through OIM post process event handler and it will be updated again in user profile of user created manually in OIM. This password is sent to User through mail.
      As this password event handler will get triggered after LDAPSnyc only, this password will not be update in AD for manually created user in OIM. So he can log into OIM with this new password but not to AD system.
      He will be able to login to AD system with same User ID but with password which was set at time of manual User Creation in OIM and not with the password updated in OIM user profile by PostProcess event handler.
    Is it possible to set password for user through PreProcess even handler implementation for Random Password generation. In this case also , the default OIM post process
    password generator will override the PreProcess event handler.How to resolve this issue.
    Also,when AD connector is in place in OIM environment we would be having change/update tasks for any attribute update to be send from OIM to AD.
    How this update scenario will be implemented from OIM to AD in case of LDAPSync ?
    Please provide any helpful pointer on this.
    Thanks,
    RPB

    Password :
    Increase order of calling for custom password event handler than OOTB handler.
    Update:
    you wanted to update custom fields?
    Did you check default update tasks comes with connector?

  • How get all record from master and matching record from detail

    hi master
    sir i have master detail table
    i have many record in master table but some record in detail table how i get
    all record from master and matching record from detail
    such as
    select m.accid,m.title,d.dr,d.cr from master m, detail d where m.accid=d.accid
    this query not work that get only related record i need all record from master
    please give me idea
    thanking you
    aamir

    hi master
    sir i have master detail table
    i have many record in master table but some record in
    detail table how i get
    all record from master and matching record from
    detail
    such as
    select m.accid,m.title,d.dr,d.cr from master m,
    detail d where m.accid=d.accid
    this query not work that get only related record i
    need all record from master
    please give me idea
    thanking you
    aamir
    select m.accid,m.title,d.dr,d.cr
    from master m, detail d
    where m.accid=d.accid (+)The outer join operator (+) will get you all the details from master and any details from the detail if they exist, but the master details will still be got even if there are not details.
    Note: Oracle 10g now supports ANSI standard outer joins as in:
    select m.accid,m.title,d.dr,d.cr
    from master m LEFT OUTER JOIN detail d on m.accid=d.accid

  • How to delete records from dynamic internal table.

    Hi Experts,
    Need urgent help!!!
    Issue is with Dynamic internal tables.
    Below is code written by me :
    FORM select_query USING Lw_tabnam
                      TYPE  t682i-kotabnr.
      DATA :  lw_line  TYPE REF TO data,
              lw_line1 TYPE REF TO data.
        CREATE DATA Lw_line    TYPE (lw_TABNAM).
        ASSIGN      Lw_line->* TO   <WA_tbl>.
        CREATE DATA LW_LINE    TYPE STANDARD TABLE OF (Lw_tabnam)
                               WITH NON-UNIQUE DEFAULT KEY.
        ASSIGN      Lw_line->* TO <TBL>.
        SELECT * FROM  (Lw_tabnam)
                 INTO CORRESPONDING FIELDS OF TABLE <TBL>
                 WHERE (t_keys).
    Endform.
    code is working fine.
    here even the table name and where condition are dynamic,everything is fine upto this point.
    Now i have to delete some record from <TBL> based on some conditons.
         for ex : ( here lc_fieldname is KUNNR)
          loop at t_kunnr.
              lw_tabix = sy-tabix.
            Read table <tbl>
                    with key (lc_fieldname) = t_kunnr-kunnr ASSIGNING <wa_tbl>.
            If sy-subrc = 0.
            *Delete
            delete <tbl> from <wa_tbl>
    delete <tbl> index  lw_tabix.
            Endif.
         Endloop.
    The above delete statement doesn't work ,even we can't use index as it gives a syntax error " something related to "index is not allowed in standard table or hash table.
    Can you help me ab't how to delete records in Dynamic internal table?
    Other option that i am thinking of is to create a static table of type dynamic table.
    means, data itab type standard table of <tbl> .I know the syntax is wrong ,however is there any way to do this?
    Thanks in advance ,
    If you have any suggestion ab't this then do let me know.
    bye,
    Gaurav.

    Hi
    I wrote this code and it works fine:
    DATA LW_TABNAM(10) VALUE 'LFA1'.
    DATA : LW_LINES TYPE REF TO DATA,
           LW_LINE  TYPE REF TO DATA.
    FIELD-SYMBOLS: <TABLE> TYPE TABLE,
                   <WA>    TYPE ANY.
    CREATE DATA LW_LINES TYPE TABLE OF (LW_TABNAM)
    WITH NON-UNIQUE DEFAULT KEY.
    ASSIGN LW_LINES->* TO <TABLE>.
    CREATE DATA LW_LINE TYPE (LW_TABNAM).
    ASSIGN LW_LINE->* TO <WA>.
    DO 10 TIMES.
      APPEND INITIAL LINE TO <TABLE>.
    ENDDO.
    SY-TABIX = 4.
    DELETE <TABLE> INDEX SY-TABIX.
    WRITE SY-SUBRC.
    I hope it help you
    Max

  • How to exclude records from one table that is contained in a second table

    I am trying to create a Crystal report that excludes records from one Table that is contained in a second table using the != link option and it is not working. I've tried all of the different enforce options, and it is still not excluding those records. Does anyone have any suggestions of what I'm doing wrong or any other suggestions how I can obtain the results I need?
    Thanks in advance!

    Have you tried by Command ?
    Thanks,
    Gordon

  • How to rerieve records from the table starting with character 'D'

    Hi Folks,
    How to get the records from the table starting with character 'D'.
    Select Max (fld1) fron tab1 into tab1-fld1 where fld 2 = l_fld2 and starting character of fld(1) is 'D'.
    last record in the table starting with character 'D'
    How can i do that??
    Pl explain.
    Thanks,
    Matt

    Hi,
    Select Max (fld1) fron tab1 into tab1-fld1 where fld 2 = l_fld2 and starting character of fld(1) is 'D'.
    Select MAX (fld1)
       From  tab1
    into table itab
    where fld 2 = l_fld2
       and fld1 like 'D%'.

Maybe you are looking for

  • How to restore my iPhone , no internet , I cloud setting on and forgot passcode

    I Have an iPhone 4 I can't remember my passcode so My phones disabled i have my iCloud setting on but not internet so  I can't restore via find my laptop or find my iPhone Please can someone tell me how to restore my phone or atleast get into it MANY

  • My dad and i share the same apple ID and now we have the same contacts. Help please

    When my dad got a new phone he got all of my contacts because we have the same apple ID so how do i get my contacts off of his phone and also if he deletes one of my contacts off of his phone it gets deleted off of my phone. Can someone help me? Than

  • Error while patching 14196234 -OIM 11g R2

    Hi, I am currently in the process of applying mandatory patches for OIM 11g R2, when I run run opatch lsinventory it succeeds, but when I run opatch apply following error is thrown: Error during Update inventory for apply phase]. Detail:OPatch failed

  • Problems with Fullscreen viewing

    I was viewing a trailer for a movie and at first I watched it at the size it opened as. I thought the trailer was good so I wanted fullscreen of it. So I click View>FullScreen. It opens up with the Green "This preview has been approved for all audien

  • Reg: Study Material (1Z0-031) - Oracle DBA OCA....

    Hi If any one have exam study material DBA OCA - Fundamentals - I as PDF file. kindly share with me. Thanks in Advance... Regds, Sathya