473,386 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Updating a Datagrid

Have two tables that have a FK relationship on ID column.

Have one datagrid that displays all of the columns of both tables.

What's the best approach on updating a row from the datagrid back to the
database?

I've used the following code for the DataGird1_UpdateCommand

Option1
**********
string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();

TextBox tbSales = (TextBox)e.Item.Cells[1].Controls[0];

string stSale = tbSales.Text;

string sql = "update table1 set Sale = '" + stSale + "' where ID= " + key;

oracleConnection1.Open();
OracleCommand cmd = new OracleCommand(sql,oracleConnection1);
cmd.ExecuteNonQuery();
oracleConnection1.Close();
DataGrid1.EditItemIndex = -1;
oracleDataAdapter1.Fill(dataSet11);
BindDataGrid1();
*******
It doesn't do a great job of updating from the datagrid to the database.
Especially if you have two tables together in one datagrid. I'm looking for a
better approach on updating.

Another way was to use the DataSet:

Option2
*******
DataSet1.DBTableRow row;

row = dataSet11.DBTable.FindByID(int.Parse(key));

row.SALE = stSale;
*****************
Does going the route of option2 offer better performance OR is there a
better way to update the datagrid than the above options? If you could show
some sample c# code that would be appreciated.

Any suggestions would be appreciated.

Thanks.

bebop
Nov 22 '05 #1
0 1015

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: cwbp17 | last post by:
Have two tables that have a FK relationship on ID column. Have one datagrid that displays all of the columns of both tables. What's the best approach on updating a row from the datagrid back to...
1
by: Patrick Delifer | last post by:
HI, I am trying to update a DataGrid where I want to rebind just the row that was updated. Here's the situation: 1) Updating is not a problem, it works fine. 2) I am not using ItemCommand (edit,...
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
0
by: cwbp17 | last post by:
I'm having trouble updating individual datagrid cells. Have two tables car_master (columns include Car_ID, YEAR,VEHICLE) and car_detail (columns include Car_ID,PRICE,MILEAGE,and BODY);both tables...
10
by: jaYPee | last post by:
does anyone experienced slowness when updating a dataset using AcceptChanges? when calling this code it takes many seconds to update the database SqlDataAdapter1.Update(DsStudentCourse1)...
0
by: Mike P | last post by:
I'm updating a datagrid which works fine, but after updating the datagrid does not return to 'view' status, remaining in 'edit' status. Has anybody else had this problem? Thanks, Mike
2
by: Greg | last post by:
I'm using the Framework 1.1, so I don't have access to the new DataGridView object. What I'm wondering is, is there a really simple way to bind a plain datagrid to a database in such a way that...
2
by: marcmc | last post by:
Hey, I have never used a datagrid/dataset/adaptor/table method for updating data, I have always used direct updates to the database so ADO is quite new to me. I have a datagrid and I change a...
0
by: Chet | last post by:
I have a Datagrid that is bound to a Datatable at runtime. I allow the user to select a number of rows using the mouse and then click a button that says "check selected rows", which then cycles...
2
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
Hi All! I am with a situation where I am not getting the right updating to the form's fields. The situation is the following one: I have one combobox and one textbox. I am using the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.