Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB datagrid column update

Status
Not open for further replies.

Tchi

MIS
Apr 17, 2003
2
US
I am currently retrieving data from Oracle tables, using an Oracle OLEDB connection (Provider=OraOLEDB), onto a VB6 datagrid which is bound to the Oracle recordset. I would like to update an individual field on the datagrid by placing the cursor directly onto the field, make the required update to that field and then pass that update back to the appropriate Oracle table.

I am a beginner with VB. Please show example code. Thanks.
 
I am assuming your connection is still open when the data is in the grid. so to update a column in a grid you can use the following

Do While Not rs.EOF

rs.Fields("Field") = DataGrid1.Columns(0).Text

rs.Update
rs.MoveNext
Loop

Column 0 is the first column in the grid.

so just change the 0 to whatever column you wish to update.

you may want to post some of your code so we can take a look.

hope this helps

 

VB datagrid column update continued. (Ver1)

The process I would like to perform is as follows:
1. Move the cursor to a particular field within the datagrid.
2. Highlight the data within the field and update that field on the datagrid.
3. Update the Oracle table.

The following code satisfies item 3
Do While Not rs.EOF
rs.Fields("Field") = DataGrid1.Columns(0).Text
rs.Update
rs.MoveNext
Loop

How do I accomplish items 1 and 2.

Need to know how to obtain the row, column values of the datagrid field, which is being updated by the current cursor position.

I am currently looking at the MSDN Library Visual Studio 6.0
RowContaining, ColContaining Method Example

How does the DataGrid1.Columns(?).Text get updated by accessing the datagrid via a mouse click, arrow key or tab key.

I would like to have the same edit capabilities on a field in the datagrid as in a text field.

 
You can Setfocus to the grid but it will put the cursor at the 0 column. why not save all the data in the grid?? if your trying to go off of the cursor position you could have problems. say a user changes several different columns in the grid and then saves the record. all the columns will not get updated since the cursor could only be at one position at a time.

Just update the whole grid back to the Oracle table. This way your sure all the data is being saved.

You may want to look at third party controls for this like VSFlexGrid.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top