-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: saileshsaha
Message 4 in Discussion

 Hi! I am trying to understand your problem and give you a solution here. But i might 
be wrong in understanding your requirement. If thats the case, correct me.   The first 
step you are taking is : displaying the records present in the excel sheet in a 
datagrid. Then based on its presence in a db table, you are either inserting it or 
updating it.    Now you want to provide edit facility on the grid. I am assuming that 
you want to provide the edit facility for the data displayed in the grid and this data 
is fetched from the database. Am i right in my assumption??? If yes, then we can 
proceed further.   Now when you fetch the data from the db table, fetch its primary 
key/unique key too if there is any. If not then you can fetch a combination of keys 
that will make a record unique. These columns are to be fetched even if they are not 
to be displayed on the grid. You can maintain extra column(s) in the datagrid for this 
unique key column and make it invisible.   Now you can provide edit facility on the 
grid. Now this editing can be (a) adding new rows (b)updating existing rows 
(c)deleting existing rows based on your requirement. Am i right here? To handle this, 
take another invisibnle column and name it changes. In this column keep on marking the 
rows as either I(for insert), U(for update) and D(for delete). Lets take one by one: 
(a) When the  value is I, ie the row is added, the user supplies the displayed values. 
Your code should generate a number and assign it for the unique key column value. This 
can be a sequential negative number for convenience. You can always maintain thsi 
sequence in your code. So when you are upating the records finally on the database, 
check on negative unique numbers. If any negative numbers found, that means thsi row 
was added to the grid and you can use insert statements.   (b) When the value is U, 
ie, when an edit is done, you can retreive the unique key value from the hidden 
column. Once you have that value along with the changed values, you can always update 
your database.   (c) When the value is D ie when a delete is done, you can retreive 
the unique key value from the hidden column. Once you have that value you can always 
delete the reocrd based on the unique key value.   Hope this solves your purpose.   
Regards, Sailesh

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDOTNET/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to