Updating Datagrid question.... - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Updating Datagrid question....

dynamicarraydynamicarray Posts: 11Member
I have made an scheduling application that allows a user to input data into text boxes then press a insert button and this information is then inserted into the database. If the user decides to view the scheduling info. then they just use a calendar datetimepicker control to search the database for the schedule. Now, the problem I am having is after they do the search for the schedule and they need to change a cell in the datagrid
I can't figure out how to get it to update to the database when a change has been in the datagrid. I am not using the IDE for my connection to the database...I am using a module that does all of my connections and holds my SQL statements in it. Anyone who can help me I would be greatly appreciative.

Comments

  • rlcrlc Posts: 448Member
    Not to familar with the basic grid object, but sounds like you need to look at what events the object can rasie. Most likely there is an event for the user editing a cell, and this could call your update routine from the module.

    ~rlc
  • dynamicarraydynamicarray Posts: 11Member
    [b][red]This message was edited by dynamicarray at 2005-4-21 14:7:30[/red][/b][hr]
    : Not to familar with the basic grid object, but sounds like you need to look at what events the object can rasie. Most likely there is an event for the user editing a cell, and this could call your update routine from the module.
    :
    : ~rlc
    :

    I have looked at all the of the events and I have narrowed down to 2 of em that it could be currentcelledit(i think thats it) and celldoubleclick but the problem I am having is not with the event it is when I go to run my SQL Update query I don't know how to update all the values in the datagrid for the row. I need some way of reading the data of the row into a array of some sort then when I use my update query I can set each index to the column in SQL. Anyone that has any suggestions or help I appreciate any and all feedback

  • rlcrlc Posts: 448Member
    I dont know a great way, I don't work with controls much. But if you wanted to do it manually you could loop the column collection for the grid and get each columns name to build the sql.

    ~rlc
  • dynamicarraydynamicarray Posts: 11Member
    : I dont know a great way, I don't work with controls much. But if you wanted to do it manually you could loop the column collection for the grid and get each columns name to build the sql.
    :
    : ~rlc
    :
    Could you show me an example of what your talking about...I think I know what you mean but I am unsure. Thanks
  • rlcrlc Posts: 448Member
    [b][red]This message was edited by rlc at 2005-4-25 12:27:49[/red][/b][hr]
    Well if you set a datatable equal to your grids source like so
    [code] Dim l_tr As DataTable
    l_tr = MyDataGrid.DataSource[/code]

    You can loop though the column collection and get each name and/or ordinal for the column. You should be able to use this to create your SQL. If you column names that you display are different fro mthe actual ones in the DB you may need a table associating these values.
    [code]For Each l_CurrCol As DataColumn In l_tr.Columns
    l_CurrCol.Ordinal()
    l_CurrCol.ColumnName()

    'build on sql

    Next[/code]

    ~rlc
Sign In or Register to comment.