DataSet Rows Being Deleted, But After The Update , The Sql Database Is Not Updated. The Delete Rows Still In The Database.

Jun 4, 2007

 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._ClientDependentChild, UserId);

        rowCountDb = cDependChildDs._ClientDependentChild.Count;
      

        for (row = 0; row < rowCountDb; row++)
        {

           dr_dependentChild = cDependChildDs._ClientDependentChild.Rows[0];
           dr_dependentChild.Delete();
          
          
//cDependChildDs._ClientDependentChild.Rows.RemoveAt(0);
          
//cDependChildDs._ClientDependentChild.Rows.Remove(0);
            /* update the Client Process Table Adapter*/
          // cDependChildTA.Update(cDependChildDs._ClientDependentChild);
      //     cDependChildTA.Update(cDependChildDs._ClientDependentChild);


        }

        /* zero rows in the DataSet at this point */

        /* update the Child  Table Adapter */
       cDependChildTA.Update(cDependChildDs._ClientDependentChild);

View 1 Replies


ADVERTISEMENT

Problem With Update When Updating All Rows Of A Table Through Dataset And Saving Back To Database

Feb 24, 2006

Hi,
I have an application where I'm filling a dataset with values from a table. This table has no primary key. Then I iterate through each row of the dataset and I compute the value of one of the columns and then update that value in the dataset row. The problem I'm having is that when the database gets updated by the SqlDataAdapter.Update() method, the same value shows up under that column for all rows. I think my Update Command is not correct since I'm not specifying a where clause and hence it is using just the value lastly computed in the dataset to update the entire database. But I do not know how to specify  a where clause for an update statement when I'm actually updating every row in the dataset. Basically I do not have an update parameter since all rows are meant to be updated. Any suggestions?
SqlCommand snUpdate = conn.CreateCommand();
snUpdate.CommandType = CommandType.Text;
snUpdate.CommandText = "Update TestTable set shipdate = @shipdate";
snUpdate.Parameters.Add("@shipdate", SqlDbType.Char, 10, "shipdate");
string jdate ="";
for (int i = 0; i < ds.Tables[0].Rows.Count - 1; i++)
{
jdate = ds.Tables[0].Rows[i]["shipdate"].ToString();
ds.Tables[0].Rows[i]["shipdate"] = convertToNormalDate(jdate);
}
da.Update(ds, "Table1");
conn.Close();
 
-Thanks

View 4 Replies View Related

Log Of Rows Inserted/updated/deleted

Apr 30, 2006

HI, I am wondering if it is possible to retreive this information without using row count transform. Can I get the # of rows inserted/updated or deleted by destination from the log?

Thank you,
Ccote

View 1 Replies View Related

ERROR - The Row Value(s) Updated Or Deleted Either Do Not Make The Row Unique Or They Alter Multiple Rows.

Sep 8, 2006

i am getting the above error on my database i have 2 rows with the same info on and another 2 with the same info on.  example:

ID    username   password

1            bob       bob

1            bob       bob

1           john       john

1           john        john

 

I know this is a fault with ms sql 2005 however how do i fix it?

Ive found this link which explains everything but how do i start a query.  I tried clicking on new query and copying the code.  What is table1 meant to be?  the database is dbl.tbl_admin.  It wont find my database.

Im not sure how to do it anyway.

I need to change it though as its my admin password and Ive given it out to web design companys

http://geekswithblogs.net/allensb/archive/2006/07/27/86484.aspx

Can some 1 read the above page and give me full instructions, I dont know what im doing thanks

info@uktattoostudios.co.uk

View 7 Replies View Related

Dataset.Clear() Doesn't Mark Rows As Deleted

Apr 18, 2007

Ok, I've spent a good amount on time on debugging an unupdating scenario in my application. Finally I knew the reason which is very annoying. Either I'm missing something really obvious (I hope so,) or this is a bug.

to reproduce what I'm talking about:
1- create a new win forms application using VS2005 sp1
2- add some SQL Compact Edition data file that have some records from the data menu, you'll get the designer to generate the dataset and everything..
3- drag a table from the data sources window, you'll get the data grid and the navigator on the form
4- add a button and have this in the click event handler:
datasetname.Clear();
TableAdapterName.Update(datasetname);

launch the program, click the button, you'll see the grid get wiped out as it supposed to do. close the program and relaunch. the data is there again (this has nothing to do with the copy always, copy if newer infamous stupidity)

now:
5- edit the click event handler and change it so something like this:
foreach (datasetname.TableRow row in datasetname.Table)
{
row.Delete();
}
TableAdapterName.Update(datasetname);

Launch the program, hit the button, grid wiped out. exit and relaunch. You'll see no data (i.e. the update on table adapter worked alright)

You can also try the GetChanges method on the dataset rightafter you use the clear method and you'd get no deleted records at all.

So, in 100,000+ records dataset, if i need to wipe the thing out and add some new records do i have to loop over every record and call delete (which will take LOTS of time).
I do hope that I'm missing something obvious.

Any help would be highly appreciated.

Thanks.

View 1 Replies View Related

Transact SQL :: Recover Deleted Rows From Server Database

Sep 23, 2011

My Client Accidently Deleted Somes Rows From Database Now. Now We are Struggling For Almost 2 Days To Get Them Backup. I Even Checked LDF File From Notepad It Have Those Rows But Not Formatted. (Some Similar Text From Some Column Which Got Deleted.)And The Database has no Backup which i Go to Task -> Restore...Server is Running on Sql Server 2008.

View 7 Replies View Related

T-SQL (SS2K8) :: Check How Many Rows Delete Updated Per Day And Store It In Another Table?

May 8, 2015

how to track how many rows updated or deleted per day in a single table and load the information in another table .

View 7 Replies View Related

Insert Multiple Rows From Dataset Into SQL Database

Aug 16, 2006

Hi,
is there anyway to insert all the rows from a dataset to SQL Server table in a single stretch..

Thanks
Anz

View 1 Replies View Related

My Dataset Is Saving Only The First Image Saved In The Database In Subsquent Rows

Mar 13, 2007

When i click upload image button when my database table has no any row, the selected image is saved(one row saved in table). If i continue and select a different image, i get no error sa if the image has been saved but when i view the images i have been saving, its strange even if i saved 10 records they all contain the first image that i saved. In short only the first image is saved the rest of the rows are just duplicates of the first row. so it basically becomes a table of ten rows but with same data rows(same image). Code is below.
Protected Sub btnupload_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim intLength As Integer
Dim arrContent As Byte()
If FileUpload.PostedFile Is Nothing Then
Lblstatus.Text = "No file specified."
Exit Sub
Else
Dim fileName As String = FileUpload.PostedFile.FileName
Dim ext As String = fileName.Substring(fileName.LastIndexOf("."))
ext = ext.ToLower
Dim imgType = FileUpload.PostedFile.ContentType
If ext = ".jpg" Then
ElseIf ext = ".bmp" Then
ElseIf ext = ".gif" Then
ElseIf ext = "jpg" Then
ElseIf ext = "bmp" Then
ElseIf ext = "gif" Then
Else
Lblstatus.Text = "Only gif, bmp, or jpg format files supported."
Exit Sub
End If
intLength = Convert.ToInt32(FileUpload.PostedFile.InputStream.Length)
ReDim arrContent(intLength)
FileUpload.PostedFile.InputStream.Read(arrContent, 0, intLength)
If Doc2SQLServer(txtTitle.Text.Trim, arrContent, intLength, imgType) = True Then
Lblstatus.Text = "Image uploaded successfully."
Else
Lblstatus.Text = "An error occured while uploading Image... Please try again."
End If
End If
End Sub
Protected Function Doc2SQLServer(ByVal title As String, ByVal Content As Byte(), ByVal Length As Integer, ByVal strType As String) As Boolean
Try
Dim cnn As Data.SqlClient.SqlConnection
Dim cmd As Data.SqlClient.SqlCommand
Dim param As Data.SqlClient.SqlParameter
Dim strSQL As String
strSQL = "Insert Into Images(imgData,imgTitle,imgType,imgLength,incident_id) Values(@content,@title,@type,@length,@incident_id)"
Dim connString As String = "Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|safetydata.mdf;Integrated Security=True;User Instance=True"
cnn = New Data.SqlClient.SqlConnection(connString)
cmd = New Data.SqlClient.SqlCommand(strSQL, cnn)
param = New Data.SqlClient.SqlParameter("@content", Data.SqlDbType.Image)
param.Value = Content
'cmd.Parameters.AddWithValue(param)
cmd.Parameters.AddWithValue("@content", Content)
 
param = New Data.SqlClient.SqlParameter("@title", Data.SqlDbType.VarChar)
param.Value = title
cmd.Parameters.Add(param)
param = New Data.SqlClient.SqlParameter("@type", Data.SqlDbType.VarChar)
param.Value = strType
cmd.Parameters.Add(param)
param = New Data.SqlClient.SqlParameter("@length", Data.SqlDbType.BigInt)
param.Value = Length
cmd.Parameters.Add(param)
cmd.Parameters.AddWithValue("@incident_id", id.Text)
cnn.Open()
cmd.ExecuteNonQuery()
cnn.Close()
Return True
Catch ex As Exception
Return False
End Try
End Function

View 1 Replies View Related

How Do You Delete (x) Number Of Rows From Database

Jan 10, 2008

I am setting up a database which schedules production and tracks inventory of items on a daily basis.  The scheduler may put in 100 identical entries (apart from the identity column) of an item with its corresponding quantity.  My problem is, if there is a shipment of product (a subtraction of quantity from the database), how can I delete a specified number of rows where the inventory listing is 100,000 pcs?  I think the DELETE TOP(r) command will work but I don't know how make the command into an actual variable.  Maybe there is another way too...
My current not-working try;  I look at the product desired to delete, figure out how many rows to delete, and since it is not always an integer, figure out a quantity to add back in.  The addition part works fine but delete command needs work.  Any help is appreciated.
    int InvRows = 0;    decimal RealInvRows = 0;    decimal AddQty = 0;    int preAddAmount = 0; protected void DelInv_Click(object sender, EventArgs e)    {        Label TotProdSum = (Label)DetailsView2.FindControl("TotProdSum");        Label RowQty = (Label)DetailsView3.FindControl("RowQty");        int SubQty = Convert.ToInt32(ShipQty.Text);        InvRows = SubQty / Convert.ToInt32(RowQty.Text) + 1;        RealInvRows = SubQty / Convert.ToDecimal(RowQty.Text);        AddQty = (InvRows - RealInvRows) * Convert.ToInt32(RowQty.Text);        IntLbl.Text = Convert.ToString(InvRows);        RealLbl.Text = Convert.ToString(RealInvRows);        preAddAmount = Convert.ToInt32(AddQty);        AddAmount.Text = Convert.ToString(preAddAmount);                for (int r = 0; r <= InvRows; r++)        {            forWhile.DeleteCommand = "DELETE TOP (r) FROM Inventory WHERE (Inventory = @Inventory)";            forWhile.DeleteParameters.Add("Inventory", RowQty.Text);            forWhile.Delete();            forWhile.DeleteParameters.Clear();        }        forWhile.InsertCommand = "INSERT INTO Inventory(Dte, Product, Inventory) VALUES (@Dte, @Product, @Inventory)";        forWhile.InsertParameters.Add("Inventory", AddAmount.Text);        forWhile.InsertParameters.Add("Product", InvProdDDL.Text);        forWhile.InsertParameters.Add("Dte", Date.Text);        forWhile.Insert();        forWhile.InsertParameters.Clear();    } 

View 1 Replies View Related

Timestamp - Automatically Update Date And Time When Rows Updated?

Apr 7, 2014

I know 2008 MS SQL Server has a timestamp data type that adds date and time when the rows are inserted. Is there a way to automatically update the date and time when the rows are updated?

View 5 Replies View Related

SQL Search :: DELETE Rows From All Tables In Database Where Column Name Is Geo And Value Is NULL

Nov 16, 2015

I need to look at all tables in a database that has a column name of GEO

Then look for all values in each table where the GEO value is NULL and delete each of the records found...

View 6 Replies View Related

SQL Server 2012 :: Strategy To Delete / Move Millions Of Rows In A Database?

Apr 16, 2015

I am using SQL Server 2012 SE.I am trying to delete rows from a couple of tables (GetPersonValue has 250 million rows and I am trying to delete 50Million rows and GetPerson has 35 Million rows and I am trying to delete 20 million rows). These tables are in TX replication.The plan is to delete data older than 400 days old.

I tried to move data to new tables from the last 400 days and it took me like 11 hours. If I delete data in chunks of 500000 then its taking a long time to rebuild indexes(delete plus rebuild indexes 13 hours). Since I am using standard edition partition wont work.

find ddl below:

GO
CREATE TABLE [dbo].[GetPerson](
[GetPersonId] [uniqueidentifier] NOT NULL,
[LinedActivityPersonId] [uniqueidentifier] NOT NULL,
[CTName] [nvarchar](100) NULL,
[SNum] [nvarchar](50) NULL,
[PHPrimary] [nvarchar](50) NULL,

[code]....

View 1 Replies View Related

How To Correctly Update A Table Which Values Can Be Either Inserted/updated/deleted On Update?

Feb 16, 2006

Hi SQL fans,I realized that I often encounter the same situation in a relationdatabase context, where I really don't know what to do. Here is anexample, where I have 2 tables as follow:__________________________________________ | PortfolioTitle|| Portfolio |+----------------------------------------++-----------------------------+ | tfolio_id (int)|| folio_id (int) |<<-PK----FK--| tfolio_idfolio (int)|| folio_name (varchar) | | tfolio_idtitle (int)|--FK----PK->>[ Titles]+-----------------------------+ | tfolio_weight(decimal(6,5)) |+-----------------------------------------+Note that I also have a "Titles" tables (hence the tfolio_idtitlelink).My problem is : When I update a portfolio, I must update all theassociated titles in it. That means that titles can be either removedfrom the portfolio (a folio does not support the title anymore), addedto it (a new title is supported by the folio) or simply updated (atitle stays in the portfolio, but has its weight changed)For example, if the portfolio #2 would contain :[ PortfolioTitle ]id | idFolio | idTitre | poids1 2 1 102 2 2 203 2 3 30and I must update the PortfolioTitle based on these values :idFolio | idTitre | poids2 2 202 3 352 4 40then I should1 ) remove the title #1 from the folio by deleting its entry in thePortfolioTitle table2 ) update the title #2 (weight from 30 to 35)3 ) add the title #4 to the folioFor now, the only way I've found to do this is delete all the entriesof the related folio (e.g.: DELETE TitrePortefeuille WHERE idFolio =2), and then insert new values for each entry based on the new givenvalues.Is there a way to better manage this by detecting which value has to beinserted/updated/deleted?And this applies to many situation :(If you need other examples, I can give you.thanks a lot!ibiza

View 8 Replies View Related

Can't Update, Insert, Or Delete Rows

Oct 20, 2007

I have recently started an ASP.Net application and am having some issues updating, inserting and deleting rows. When I started working with it, I was getting errors because it could not find any update command. Eventually, I figured out how to automatically generate the commands, by configuring my SQLDataSource control and clicking the "advanced" button. Right now though, I have generated the commands, but I still can not insert, update or delete rows. When I attempt to update anything, I recieve an error that says "The data types text and nvarchar are incompatible in the equal to operator." Nowhere in my table do I have any rows that use the datatype "nvarchar", only "text" and "int". I tried switching all of my text columns to "nvarchar(500)", which did not help. I am led to believe that the auto generated SQL procedures are trying to do something behind the scenes that is making my database act up, because even when I delete rows, I get the same exception, so the datatypes cannot be messed up there, because all that the datasource is doing is deleting rows, therefore there is no need to worry about data types. I only get the error when I check the "Use optimistic concurrency" box. When I do not use optimistic concurrency, I can delete, insert, and update rows... but nothing happens. There are no errors, but nothing is deleted, updated or inserted either. Upon postback, nothing has changed. I may upload a copy of the exact exception page, if someone thinks that it may help. Here is the update command that was generated: UPDATE [Record Information] SET [Speed] = @Speed, [Recording Company] = @Recording_Company, [Year] = @Year, [Artist] = @Artist, [Side 1 Track Title] = @Side_1_Track_Title, [Side 1 Track Duration] = @Side_1_Track_Duration, [Side 2 Track Title] = @Side_2_Track_Title, [Side 2 Track Duration] = @Side_2_Track_Duration, [Sleeve Description] = @Sleeve_Description WHERE [Record Database ID] = @original_Record_Database_ID
Apparently no stored procedures exist for any of these operations, and I am unsure why. The "Record Database ID" is my identity column, and is the only field that is (and is supposed to be) uneditable.

View 1 Replies View Related

Need To Update Table To Delete Rows

Oct 2, 2007

what is wrong with this statement?

Update services
Delete
where ticketnum = '0'

error message: incorrect syntax near keyword delete

View 6 Replies View Related

How Can I Set A Update Trigger On A Table In Database A After A Record Had Been Updated From Another Database B?

Jan 22, 2008



Hi guys, may I know is it possible to create an update trigger like this ? Assuming there are two database, database A and database B and both are having same tables called 'Payments' table. I would like to update the Payments records on database A automatically after Payments records on database B had been updated. I can't use replication because both tables might having different records and some records are the same. Hope can get any assistance here, thank you.

Best Regards,
Hans

View 8 Replies View Related

SQL Server 2012 :: Update Statement Will Not Update Data Beyond 7 Million Plus Rows Out Of 38 Millions Rows

Dec 12, 2014

I run the following statement and it will not update beyond 7 million plus rows and I have about 38 million to complete. I keep checking updated row counts and after 1/2 day it's still the same so I know something is wrong because it was rolling through no problem when I initiated it. I need to complete ASAP so it's adding to my frustration. The 'Acct_Num_CH' field is an encrypted field (fyi).

SET rowcount 10000
UPDATE [dbo].[CC_Info_T]
SET [Acct_Num_CH] = 'ayIWt6C8sgimC6t61EJ9d8BB3+bfIZ8v'
WHERE [Acct_Num_CH] IS NOT NULL
WHILE @@ROWCOUNT > 0
BEGIN
SET rowcount 10000
UPDATE [dbo].[CC_Info_T]
SET [Acct_Num_CH] = 'ayIWt6C8sgimC6t61EJ9d8BB3+bfIZ8v'
WHERE [Acct_Num_CH] IS NOT NULL
END
SET rowcount 0

View 5 Replies View Related

Can't Delete Records From DB .. Says : Too Many Rows Were Affected By Update.

Jun 1, 2004

Hi,

I've added multiple records with same info during practice. Now I"m trying to delete those records from SQL Server DB. but it says

"Key column information is insufficient or incorrect. To many rows were affected by update."

What to do, to delete these records?

Appreciated..

View 2 Replies View Related

Insert, Update, Delete Rows In A VIEW ....

Dec 27, 2007

Hello,

Is it possible to insert rows into a view, update rows in a view and delete rows in a view?
If so, how does T-SQL handle it when a VIEW is the result of following query?

CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name1
INNER JOIN table_name2 ON table_name1.col = table_name2.col
WHERE condition

Thanks in advance,
Erke.

View 4 Replies View Related

How To Create A Trigger Such That It Can Delete The Rows Whenever Any Other Application Such As Biztalk Had Read The Rows ?

Mar 12, 2007

I had created a trigger which sees that whether a database is updated if it is its copy the values of the updated row into another control table now I want to read the content of control_table into BIzTalk and after reading I want to delete it.Can any one suggest the suitable ay to do this?

View 3 Replies View Related

Rows Affected From Insert,update,delete Using SQLDMO

Feb 8, 2000

I am using SQLDMO to implement a tool to do basic management/script running for a MSDE database. The problem i am having is getting the number of rows affected from insert,update,delete statements. Help and MSDN seem to imply that this info is returned in a QueryResults object, but it is always empty unless the query is a select statement. I tried using ExecuteImmediate, ExecuteWithResults, and ExecuteWithResultsAndMessages methods and the info is not in any resultset, message, or property.

mikem

View 2 Replies View Related

Transact SQL :: Table Trigger To Delete All Rows Before Inserting Rows

Jul 24, 2015

I have a SQL script to insert data into a table as below:

INSERT into [SRV1INS2].BB.dbo.Agents2
select * from [SRV2INS14].DD.dbo.Agents

I just want to set a Trigger on Agents2 Table, which could delete all rows in the table , before carry out any Insert operation using above statement.I had below Table Trigger on [SRV1INS2].BB.dbo.Agents2 Table as below: But it did not perform what I intend to do.

USE [BB]
GO
/****** Object:  Trigger    Script Date: 24/07/2015 3:41:38 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON

[code]....

View 3 Replies View Related

Does The UPDATE Trigger Fire When A Record Is Updated Or Only When It Is Deleted?

Jun 15, 2004

I've gotten conflicting info about this in the past so I thought I'd try to get clarification.

When a record is deleted, I'm sure it fires the delete trigger. Does it also fire the update trigger?

Thanks

View 3 Replies View Related

Update A Dataset From An Updated MSSQL Table

May 23, 2007

Here is my problem: I've created a table in MSSQL named MyReferences and then a typed dataset to connect to it.



Then I realized that I needed to add a column to MyReferences table and then I did it.



The problem is that I cannot find a way to add the new column to the typed dataset. I am unable to view it in the available columns.



Can anyone help me?



I'm using Visual Studio 2005 sp1 and C#.



Best regards



Alessandro

View 1 Replies View Related

#of Rows Updated

Oct 10, 2007

Is there a command that will tell me the number of rows that are updated in a statement. I would like to put this in an Stored Procedure and pass the #rows updated back out.

View 1 Replies View Related

How To See Who Deleted Rows

Feb 1, 2008



5 accounts have access to database, is it possible to see or log who deleted any records?

Thank you

View 4 Replies View Related

Dataset.Tables.Count=0 Where There Are 2 Rows In The Dataset.

May 7, 2008

Hi,
I have a stored procedure attached below. It returns 2 rows in the SQL Management studio when I execute MyStorProc 0,28. But in my program which uses ADOHelper, it returns a dataset with tables.count=0.
if I comment out the line --If @Status = 0 then it returns the rows. Obviously it does not stop in
if @Status=0 even if I pass @status=0. What am I doing wrong?
Any help is appreciated.


ALTER PROCEDURE [dbo].[MyStorProc]

(

@Status smallint,

@RowCount int = NULL,

@FacilityId numeric(10,0) = NULL,

@QueueID numeric (10,0)= NULL,

@VendorId numeric(10, 0) = NULL

)

AS

SET NOCOUNT ON

SET CONCAT_NULL_YIELDS_NULL OFF



If @Status = 0

BEGIN

SELECT ......
END
If @Status = 1
BEGIN
SELECT......
END



View 4 Replies View Related

Tracking Updated Rows

Nov 7, 2013

so i have an update query that is updating 50k rows per batch. my question is how do i campture how long it is taking to update 50k rows per batch.

View 3 Replies View Related

Get Number Of Rows Deleted

Feb 1, 2006

How do we get the number of rows deleted from a table?

@@rowcount is returning 0

View 2 Replies View Related

Find Out Who Deleted Rows?

Jan 20, 2004

Yesterday, I had an occurence where someone (one of our developers :) ) deleted many vital rows in a database. I was able to recover via a backup but I'd like to see what was run to delete those rows, when and who if possible? I have the transaction log and the _log.ldf.

Can I read those somehow to find out this information? I have since added auditing to said tables, but I'd really like to go back and see what happened?

I do know about Lumigent, but is there a different production/solution?

Thoughts?

Thank you

View 2 Replies View Related

Retrieve Deleted Rows

Jan 7, 2008

Hello all,

I've just deleted some rows by error in one of my tables. I'd like to find out a quick way to retrieve them.
I'm using MSSQL server 2000, version 8.00.194

Thank you in advance

View 9 Replies View Related

Returning The Primary Key Of The Last Rows Updated

Apr 28, 2005

I would like to return the the Primary Key of the row altered from this query - what changes do I need to make?

UPDATE Members SET LastLog = @time WHERE UserName=@user AND Password=@pass;


Thanks in advance,

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved