467,207 Members | 1,357 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,207 developers. It's quick & easy.

Problem in Updating Dataset to database using SQL Adapter

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,"WFF");
//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
  • viewed: 1795
Share:
3 Replies
8TB
See if this helps.
Aug 12 '08 #2
Hi,

My Code is
: SqlDataAdapter SDA = new SqlDataAdapter("Select * from WFF", DAC.Conn); SDA.Fill(dt,"WFF");
//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
Expert 2GB
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

Post your reply

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

Similar topics

7 posts views Thread by Zachary Hilbun | last post: by
3 posts views Thread by Grant | last post: by
5 posts views Thread by Brad Baker | last post: by
16 posts views Thread by fniles | last post: by
5 posts views Thread by Usman Jamil | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.