473,811 Members | 2,324 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Where to put the SQLDataAdapter. Update() method?

I am having problems with updating the changes done over a DataSet to a
Database.
All the changes being done using the Form are stored in the Dataset, but
when i decide to close the Form and open the form again, the changes are lost.
Also, the modification process works great, but adding or deleting a row
doesn't work.
I am using a SQLDataAdapter to manage all the
insert/delete/modification/select over the table.
I supose the problem is caused because i am calling:
this.sql_DA_Tab le.Update(this. Dataset)
in the wrong place.
Where i should use it?
in the Dataset.ChangeR ow event?
in the Dataset.Changin gRow event?
in the Dispose event?
in another place?

Thanks for your time.
Nov 16 '05 #1
3 4361
hi
in the closing event of the form
check this
if(myDataSet.Ha sChanges(DataRo wState.Modified ))
update the dataset to db

only one thing you should take care is that you call it before you accept
the changes DataSet.AcceptC hanges

regards
ansil
"Fernando" wrote:
I am having problems with updating the changes done over a DataSet to a
Database.
All the changes being done using the Form are stored in the Dataset, but
when i decide to close the Form and open the form again, the changes are lost.
Also, the modification process works great, but adding or deleting a row
doesn't work.
I am using a SQLDataAdapter to manage all the
insert/delete/modification/select over the table.
I supose the problem is caused because i am calling:
this.sql_DA_Tab le.Update(this. Dataset)
in the wrong place.
Where i should use it?
in the Dataset.ChangeR ow event?
in the Dataset.Changin gRow event?
in the Dispose event?
in another place?

Thanks for your time.

Nov 16 '05 #2
ok, gonna try it, thanks!

"Ansil MCAD" wrote:
hi
in the closing event of the form
check this
if(myDataSet.Ha sChanges(DataRo wState.Modified ))
update the dataset to db

only one thing you should take care is that you call it before you accept
the changes DataSet.AcceptC hanges

regards
ansil
"Fernando" wrote:
I am having problems with updating the changes done over a DataSet to a
Database.
All the changes being done using the Form are stored in the Dataset, but
when i decide to close the Form and open the form again, the changes are lost.
Also, the modification process works great, but adding or deleting a row
doesn't work.
I am using a SQLDataAdapter to manage all the
insert/delete/modification/select over the table.
I supose the problem is caused because i am calling:
this.sql_DA_Tab le.Update(this. Dataset)
in the wrong place.
Where i should use it?
in the Dataset.ChangeR ow event?
in the Dataset.Changin gRow event?
in the Dispose event?
in another place?

Thanks for your time.

Nov 16 '05 #3
Ok, now i have tried it and it worked, thanks.

But i have one big question now...
I have now removed from the database the Autoincrement feature for the ID
column, I moved it to the Dataset containing the same scheme of that table
(so, the SQLDataAdapter will receive the ID as a parameter to include it in
the database).
If i ever use this from more than one PC (supose i set up a SQL Server and
two PC connected over a LAN to get the data) I will have a LOT of concurrency
problems with this setup...
If i always wait until the form is closed to make all the updates i could
create HUGE disasters if both users access at the same time.
To put an example, lets supose userA and userB opens the application at the
same time, both go to the Providers Form.... userA starts creating some new
providers... userB starts creating other new providers.
Since both got the same original data, their new providers will start after
the last ID that they have (Autoincrement feature of the Dataset)...
The first one to close the form will be the one to put the changes on the
database, the other will just receive an exception...
How i can avoid that?
Any help will be great.... right now i will not have problems, but if in the
future i expand the application... everything will have to be changed...

"Fernando" wrote:
ok, gonna try it, thanks!

"Ansil MCAD" wrote:
hi
in the closing event of the form
check this
if(myDataSet.Ha sChanges(DataRo wState.Modified ))
update the dataset to db

only one thing you should take care is that you call it before you accept
the changes DataSet.AcceptC hanges

regards
ansil
"Fernando" wrote:
I am having problems with updating the changes done over a DataSet to a
Database.
All the changes being done using the Form are stored in the Dataset, but
when i decide to close the Form and open the form again, the changes are lost.
Also, the modification process works great, but adding or deleting a row
doesn't work.
I am using a SQLDataAdapter to manage all the
insert/delete/modification/select over the table.
I supose the problem is caused because i am calling:
this.sql_DA_Tab le.Update(this. Dataset)
in the wrong place.
Where i should use it?
in the Dataset.ChangeR ow event?
in the Dataset.Changin gRow event?
in the Dispose event?
in another place?

Thanks for your time.

Nov 16 '05 #4

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

Similar topics

5
2028
by: DraguVaso | last post by:
Hi, I know there is some way to select only the new rows (and not the deleted, changed etc) in a DataGrid, and insert them in the DataBase. I want to do this by using a SqlDataAdapter. Does anybody knwo how to doe this? Thanks,
1
2108
by: Steven Blair | last post by:
Hi, Here is a short decsription of my problem. I have written a dll for Database accessing. I have one method which can return a Dataset and another method which takes a Dataset and upates a Database. (Disconnected Datasets). The problem I have is a new SqlAdapter is required before updating the Database: Therefore, to allow the update I have to do the following:
3
12297
by: Christoph | last post by:
I'm delving into using ADO.NET for the first time. In fact, I've never done any database work using C# at all so all of this is new to me. Please bear that in mind if I am asking stupid questions. In reading the documentation for the "Update()" method of the SqlDataAdapter class, I see that it "Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated or deleted rows in the specified array of DataRow objects"....
1
11069
by: Jason Huang | last post by:
Hi, In the ASP.Net, it seems it can update data in different ways. It is my impression that we can use the SqlCommand or SqlDataAdapter to update data. But I'm wondering which method is better, and according to what rules? Any help will be appreciated. Jason
5
1791
by: ypul | last post by:
the code below given is connection class ... now I want to use the connection in another class , by using the getConnection method. where should I call con.dispose() ? in connection class or in the caller class ? if I call con.dispose in connection class as given below ..will I be able to use the connection in the other class where I am calling this method ..or I will get a NULL connection ??
2
2613
by: Aaron | last post by:
Hello, The SqlDataAdapter has 4 properties of type SqlCommand, SelectCommand, UpdateCommand, DeleteCommand, and InsertCommand. Setting the SelectCommand allows the SqlDataAdapter to retrieve data from the database using the fill method. Aside from that, I don't see much of a difference. The SelectCommand can be used to insert, update, and delete all by using the ExecuteNonQuery method. So UpdateCommand, DeleteCommand, and...
4
4840
by: Matteo Migliore | last post by:
Hi. I writed a method that takes two DataTable with same schema and return a third DataTable that: - insert new rows from "compare" DataTable - delete rows contained in "source" and not in "compare" DataTable - update rows from "compare" -------------------------------------- public static DataTable GetMergedTable(DataTable source, DataTable compare)
1
1153
by: Sharma Neha | last post by:
I hav a problem in sql query.I m using C#.net and working on window form,Database is SqlSever. There is a table tracking which has key_no,status as its field. There is another table master which has slno,key_no,etc as its field. In my form i hav a textbox in which one enters slno,so using this slno i want to get key_no from master table using Select query and then use this key_no to update the status in tracking table. I have used the...
8
2473
by: Benniit | last post by:
Am using Vb.NET 2008 and SQL 2008. I have a problem, when the execution reaches daAdapter.Update(dtTable) then I receive this error ""String or binary data would be truncated. The statement has been terminated"" Then the record fails to update. What could possibly be the error? Below is the complete code. Thanx in advance. Dim SQLCon As SqlConnection Dim SqlQuery, SqlQuery1 As String Dim daAdapter As SqlDataAdapter ...
0
9728
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10389
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10402
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10135
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7670
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6890
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4339
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3018
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.