473,748 Members | 7,377 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem in Updating Dataset to database using SQL Adapter

37 New Member
I am using SQL Adapter to select data from a table in SQL Server Database. After creating Object I am filling that to a datatable. Assum that dataset has 5 row. After that I m updating that dataset and add 3 more rows. but not able to update that dataset to database table.
My code is following.

SqlDataAdapter SDA = new SqlDataAdapter( "Select * from WFF", DAC.Conn); SDA.Fill(dt,"WF F");
//Updates dt here
SDA.Update(dt);

It does not update to database so please tell me wheres the problem and solution as i have wasted near about whole day on this.
Aug 12 '08 #1
3 2069
r035198x
13,262 MVP
See if this helps.
Aug 12 '08 #2
sachinkale123
37 New Member
Hi,

My Code is
: SqlDataAdapter SDA = new SqlDataAdapter( "Select * from WFF", DAC.Conn); SDA.Fill(dt,"WF F");
//Updates dt here
SDA.Update(dt);

suppose 'dt' contains
1 Sachin 10000
2 Sam 10000
3 XYZAB 20000

I add 2 more rows
now my dt looks like
1 Sachin 10000
2 Sam 10000
3 XYZAB 20000
10 David 10000
15 Rick 50000

I m able to see 5 record in dt.
but update that dt to 'WFF' table.
compiler is not giving any error at SDA.Update(dt); but now also updatin table.
Aug 12 '08 #3
Curtis Rutland
3,256 Recognized Expert Specialist
Based on the code you provided, you never gave your DataAdapter an INSERT or UPDATE command.

The data adapter must have these commands, as well as a DELETE command, to successfully update your table. You can use a CommandBuilder.

Read this howto. I show you how to use commandbuilders and how to update datasets.
Aug 12 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
1861
by: Zachary Hilbun | last post by:
The below is some test code to help me learn how to update a dataset. It is supposed to read the value of UserCounter and write it back. The UserCounter is being read correctly as 0, is 1 when written back, but is not being written back to the database. Although I've used a foreach loop there is actually only 1 record in the dataset. I'm going to eventually use transactions but have commented them out for now
14
2129
by: Lars Netzel | last post by:
A little background: I use three Datagrids that are in a child parent relation. I Use Negative Autoincrement on the the DataTables and that's workning nice. My problem is when I Update these grid and write to the database and I set the new Primary Keys and related Fields to the new asigned atuonumbers in the Access.
11
3070
by: Eych | last post by:
I get a VB error when I try to update a table whose field I change with the following statement: dcUpdate.Dataset.Tables(0).Rows(0)("User Name") = Me.textbox1.Text if I change the field name to "UserName", one word, in the table and in the statement above, it works... realistically, I can't do this since the users already have a copy of
3
1837
by: Grant | last post by:
I need some sample code showing how to manipulate data in my access database using C#. This is what Im trying to do: Dropdownlist with datagrid both bound to datasource. When the drop down list value changes - the datagrid values change accordingly. I managed to get this working by setting the currencymanager to the dropdownlist selectedIndex (which is probably the wrong way to do it, bu the datagrid seems to update its values correctly)...
1
2035
by: r2destini | last post by:
Hi Friends, I am new to .Net. So I don't know much. I am facing a problem in updating database through ADO.Net I am creating the dataset and there is no problem in the updation and deletion or insertion in the dataset but when I am updating the
5
2615
by: Brad Baker | last post by:
I'm trying to write a simple asp.net page which updates some data in a SQL database. At the top of the page I have the following code: <%@ Page Language="C#" Debug="true" %> <%@ import namespace="System.Data" %> <%@ import namespace="System.Data.SqlClient" %> <script language="c#" runat="server"> public void Page_Load(object sender, EventArgs e) {
16
6308
by: fniles | last post by:
I am using VB.NET 2003, SQL 2000, and SqlDataAdapter. For every record in tblA where colB = 'abc', I want to update the value in colA. In VB6, using ADO I can loop thru the recordset,set the values of colA and call the Update method. How can I do this in VB.NET and SqlDataAdapter ? Thank you. m_cmdSQL = New SqlClient.SqlCommand With m_cmdSQL .Connection = adoCon
0
1700
by: OldStd | last post by:
Updating data using 2 data sets I am having some problems in updating the database using two datasets as suggested by someone. 1. Data is displayed in a data grid from a dataset generated using the IDE that pulls data from two tables using an . The idea is to display the associated with the field. Because an is used, the IDE couldn’t auto-generate the Insert command, update command, or Delete command. 2. As a result, it was suggested...
5
3397
by: Usman Jamil | last post by:
Hi I've a class that creates a connection to a database, gets and loop on a dataset given a query and then close the connection. When I use netstat viewer to see if there is any connection open left, I always see that there are 2 connections open and in "ESTABLISHED" state. Here is the piece of code that I'm using, please tell where I'm doing it wrong. Since this class is being used at many placed in my actual web based application that...
0
8828
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,...
1
9319
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
9243
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
6795
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
6073
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();...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3309
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
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2213
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.