How to update Data of First row when I delete Data of Second row?

 

assume my Table's Columns looks like below

1  ,   Annie,   History, pass, 1
2  ,   Colin,   Math   , Pass, 1
7  ,   Annie,   History, Fail, 0
11 ,   Colin,   Math   , Fail, 0


you can see the No1 and No7 with same people Annie
When I delete the No7's Data I want to update which last 2 columns "Fail" and "1" to No1
so After I delete Row of No.7 the result will looks like below



1  ,   Annie,   History, Fail, 0 ( update this row's last 2 columns ) 
2  ,   Colin,   Math   , Pass, 0
11 ,   Colin,   Math   , Pass, 0

if I going to delete the row of No11 the result would be


1  ,   Annie,   History, pass, 1
2  ,   Colin,   Math   , Pass, 1
7  ,   Annie,   History, Fail, 0


can you teach me how to do it ? wirte this request in Code or useing SQL Script?
thank you

0
jcjcjc
1/31/2008 6:20:11 AM
asp.net.getting-started 91979 articles. 4 followers. Follow

4 Replies
667 Views

Similar Articles

[PageSpeed] 20

I dont quite get it.?

Are you using a GridView or you want it to be updated Directly from ur database table?

0
Stormbind
1/31/2008 6:58:47 AM

 thank you , I want to update Data from DB after I delete row of Data

sorry for the confused... please let me explain my question again with another example

here is my columns of Table 

1  ,   Annie,   History, pass, null
2  ,   Colin,   Math   , Pass, null
7  ,   Annie,   History, Fail, 1
11 ,   Colin,   Math   , Fail, 2

 when I delete the row 11, you can see the last column shows "2" , that means row 11 is reference with row 2

so when I delete row 11 , first I need to get the column which record "Fail" or "Success" and then update the value to row 2

so after Row 11 is been deleted , the result would looks like below

 1  ,   Annie,   History, Fail, null
2  ,   Colin,   Math   , Pass, null
7  ,   Annie,   History, Fail, 1

 I think I need a SQL script to done this job... just don't know how to do

thank you  

 

 

0
jcjcjc
1/31/2008 7:18:59 AM

 delete from Table where Name = "Colin" and Subject != null

Assumption:

I am assuming that  last column is Subject which will not be null when 3rd column having the data "Fail"

 

 


Muhammad Usman
Please remember to click "Mark as Answer" on this post if it helped you.
www.usman-bhatti.blogspot.com
0
usmanbhatti531
1/31/2008 8:10:57 AM

 IF the last columns is Null then let it be Null still..

 delete from Table where Name = "Colin" and Subject != null  ( this is s delete statement)

How do I catch the column "Fail" and use this column to update another row?

 

thank you ~!! 

0
jcjcjc
1/31/2008 8:17:30 AM
Reply:

Similar Artilces:

ADO.net problem: i can not view image data for the rest of my table rows except the image for the first row but i can read all the other non image fields for all rows.
Hi i have a table with the following fields imgid............int imgdata........image imgtitle.........varchar(max) imgType........varchar(max) imgLength.....bigint incident_id.....int i have no problem with uploading the image but viewing the uploaded image(s) in a gridview has caused me great pain. The probelm is i have two pages. page1 grabs the image to display and page2 has a gridview that displays the grabed image. I wanted to have an sql statement like SELECT * FROM mytable WHERE incident_id=someValue. IF i have 5 records in this table and i view page2 ...

Why does it not let me type data in my database fields and gives me error "No row was updated, the data in row 1 was not committed?
Hi, I'm typing example records in my database fields for username, last name, firstname, city, state, etc directly into the database field but when I try to save it it says:  No row was updated. The data in row 1 was not committed.Error Source: .NetSqlClient Data Provider.Error Message: String or binary data would be truncated.The statement has been terminated.Correct the errors and retry or press ESC to cancel the change(s) Basically I'm just typing data into the fields but it won't allow me to save them.    The data types are all saved as...

How to get data from database row by row
I try to get data from a database row by row, I am using DataReader, the return result is not I expected, don't know how to solve it. Here is my sample code: --------------------------------------------Dim commandText As String = "select * from customer "Dim con As New OleDbConnection("Data Source=c:\company.mdb;Persist Security Info=False; Provider=Microsoft.Jet.OLEDB.4.0;")Dim Cmd As New OleDbCommand(commandText, con)Dim reader As OleDbDataReader = Cmd.ExecuteReader()             Using con       &nbs...

how delete a 1 row data in data table?
hi ! i know this is a newbie type of question! Im afraid! anyone knows how delete a 1 row data in data table? thanks in advanced!practice makes perfect but nobody is perfect so why practice! You can remove a row one of two ways. DataTable.Remove(DataRow)DataTable.RemoveAt(Index) HTH,RyanRyan OlshanASPInsider | Microsoft MVP, ASP.NEThttp://ryanolshan.comHow to ask a question...

update: how to delete a row only if the row is selected first
i have tried everything to get past this error and im finding it hard to delete a row from my database, can any1 help? code so far - delete with confirmation:   <asp:GridView ID="GridView1" runat="server" AllowPaging="True" CellPadding="4" ForeColor="#333333" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" DataKeyNames="fileID" OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_RowDataBound" OnRowDeleting...

Getting data from a deleted row
I have a datatable that has row containing information about a person in the system. If someone goes in and deletes that row, I do row.Delete(), but do not do table.AcceptChanges(). When the user hits save changes, I loop through the rows, see if a row has been deleted, and then I need to delete information from multiple tables regarding this person. When I try and get a value from the row where the state is deleted, I get an error saying that the data in a deleted row cannot be accessed. Is there anyway that I can get access to this data? Thanks! Create a view with RowStateFi...

Get data from first row
I've got a dataset / datatable.But i only use the first row of it... i think i can get the items easyer just from 1 row? datatable.firstrow.row["header"]   ore something like that... Right now i use:             DataTable dt = ds.Tables[table];                        foreach (DataRow row in dt.Rows)            {      ...

is it possible to avoid getting fresh data when i delete a row in delete command of datagrid?
hi i ve wriiten code like this here i need to avoid getting fresh data from database inspite of that i want to delete the row in datagrid which i deleted in the database is this possible here is my code.Label rangeId = (Label)e.Item.FindControl("lblRangeId"); //deleting the rows near rangeid.DataSet dsDeleteRange = SqlHelper.ExecuteDataset(trans, CommandType.Text, "Delete tPrintServiceRange where RangeId=" + rangeId.Text);lblMessage.Text = "Data Deleted Sucessfully."; lblMessage.ForeColor = System.Drawing.Color.Green; Bindgrid();pavankumar I guess it wo...

Getting second row in a data source
Hi,I'm generating a report where 3 photos can be shown on a report if there are 3 photos in our data source.they are layed out with the main photo on the left, and the other 2 photos on top of each other on the right.The dataset that is returned from the query has a column called PhotoURL and each photo is a row of the returned datasetI have inserted three images on the reportThe first image I set the value to be =First(Fields!PhotoURL.Value, "Image")How do you get the second image to have a value of the second row of the dataset, I mean there is no Second function, or movenext...

Get GridView row data before Deleting
Hi  I have a gridview with enabled Deleting option.i want to get all the information of the Row being deleted. Any idea?  Thanks Are you doing this so you can undo your deletes?  How do you want to delete the records - do you have a deleted flag in your table so that the record won't show in your view or are you really want to delete the records for ever and ever?  Do you want to store the most recent delete in memory so you can add it back?  In that case, store it in class-level variables in the Row_Deleting event.  Actually you could declare those...

How to get the data of a particular row in gridview without editing that row.
I have a gridview in a page in that ihave hyperlink as one column on click of that i want to go next page with the data present in that corresponding row. How shell i read the data from grid view for that pirticular row.On which event i can get the data. HI, the row that is selected should be passed into a string or an array or in sessionsthis can be done through this code  protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)    {        Label _lbl = new Label();      &...

getting the underlying for a datagrid row when the data source is a data reader
HiWhen the data source for my datagrid is a dataset I get the corresponding DataRow for the selected DataGridItem as follows:Dim pk as integer = grid.DataKeys(grid.selectedIndex)Dim dt as DataTable = grid.DataSource.Tables(grid.DataMember)Dim dr as DataRow = dt.Rows.Find(pk)How do I do the equivalent when the data source is a data reader. Thanks andrea...

DataSet rows being deleted, but after the update , the sql database is not updated. The delete rows still in the database.
 Stepping thru the code with the debugger shows the dataset rows being deleted.   After executing the code, and getting to the page presentation. Then I stop the debug and start the page creation process again ( Page_Load ).    The database still has the original deleted dataset rows. Adding rows works, then updating works fine, but deleting rows, does not seem to work.   The dataset is configured to send the DataSet updates to the database. Use the standard wizard to create the dataSet.     cDependChildTA.Fill(cDependChildDs._ClientDependentC...

Data Set ---- Data Row ( How to retrieve column data in a array )
Question regarding Dataset in ASP.NET ds = DBFunctions.RunSelect("select * from emp where Userid='" & vUserID & "'") If (ds.Tables(0).Rows.Count > 0) Then Dim dr As DataRow = ds.Tables(0).Rows(0)location= dr("location")  -- this statement only gives me the first locaitonMytable userid          location111              AAA111              BBB111         ...

Web resources about - How to update Data of First row when I delete Data of Second row? - asp.net.getting-started

Saturday Night Live Weekend Update Thursday - Wikipedia, the free encyclopedia
Saturday Night Live Weekend Update Thursday is an American limited-run series broadcast on NBC . It is a political satire news show spin-off ...

Gizmodo.com Updates
Nobody should have to use a pay phone , natural disaster or no natural disaster. So if your gadgets are out of juice after Sandy, here’s a tiny ...

Lifehacker.com Updates
By Whitson Gordon Ever run into a situation where you have multiple wireless networks available, but one is clearly better than the other? WiFi ...

Facebook Messenger For Android Update Includes Conversation Shortcuts
Facebook released an update to its Android Messenger application that incorporates the group -creation and message forwarding features in last ...

Canada Fiscal Update: Liberals Say Federal Books Billions Deeper In Hole 162
Finance Minister Bill Morneau's update comes after months of downgraded economic projections.

Rice Krispies Updates Treat Making With New Jingle
The words snap, crackle and pop first appeared in a print ad for Rice Krispies in 1929 and popped up on the box in 1932. The three characters ...

U.S. HTC One A9 to receive November security update imminently [Updated]
... to U.S. unlocked A9s. November security patch should get technical approval today and roll out immediately to U.S. unlocked A9s. Update: According ...

Winter is coming as Cartoon Survivor goes to the Ice Age in latest update
Cartoon Survivor , the fun game from the folks at Australia-based studio Spunge Games, has received a great update just in time for the cold ...

7-Zip gets a major update at last
After five years of stop-start development, 7-Zip has just released a new stable version 15.2 . It’s been a long wait, but if you’re still using ...

Colin Kaepernick Injury Update: San Francisco 49ers Place QB on Season-Ending IR - Bleacher Report
Possibly signaling the end of Colin Kaepernick 's tenure in San Francisco, the 49ers surprisingly placed the struggling quarterback on injured ...

Resources last updated: 11/22/2015 2:32:27 PM