473,326 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

DataAdapter.Update isn't doing anything

Joe
I have a really simple application for inserting/updating record in a table.
The app uses a sqlConnection, sqlDataAdapter and a dataset.

I bind the fields to text boxes and a grid to allow for the insert/editing.
I also have a button that does a Table.NewRow() and another to do the save.
I tried using sqlDataAdapter1.Update(dataset11) but nothing seems to change.
No new records, no errors.

I'm sure this is really easy and I'm probably just missing something here.
Nov 16 '05 #1
4 1794
Hi,

Could you supply some code showing what your doing? will make it easier if i
can see what your trying to do.

Regards

Darryn

"Joe" <J_no_spam@_no_spam_Fishinbrain.com> wrote in message
news:ey**************@TK2MSFTNGP10.phx.gbl...
I have a really simple application for inserting/updating record in a table. The app uses a sqlConnection, sqlDataAdapter and a dataset.

I bind the fields to text boxes and a grid to allow for the insert/editing. I also have a button that does a Table.NewRow() and another to do the save. I tried using sqlDataAdapter1.Update(dataset11) but nothing seems to change. No new records, no errors.

I'm sure this is really easy and I'm probably just missing something here.

Nov 16 '05 #2
Joe
Sorry - should have posted this:

I also have a datagrid on the form which uses the same dataSet11.Tables[0]
datasource.

I actually noticed some other strange things like when I click the new
button, a new row is returned but the count for the currencyManager doesn't
increase and a new row is NOT added to the grid.
If I click on the last row in the grid and hit the down arrow to add a row,
I can enter the values but they don't get saved. If I do it again, another
row is added but when I exit a field it changes the value to null.

private void Form1_Load(object sender, System.EventArgs e)
{
sqlDataAdapter1.Fill(this.dataSet11);
sqlDataAdapter2.Fill(this.dataSet11);
BindControls(dataSet11.Tables[0] );
}

private void BindControls(DataTable table)
{
textBox1.DataBindings.Add("Text", table, "Name");
textBox2.DataBindings.Add("Text", table, "Desc");
textBox7.DataBindings.Add("Text", table, "ModelNum");

this.m_currencyManager = (CurrencyManager)this.BindingContext[table];
m_currencyManager.Position = 0;
}

private void New_Click(object sender, System.EventArgs e)
{
DataRow dr = this.dataSet11.Tables["Products"].NewRow();
dataSet11.Products.Rows.Add(dr);
m_currencyManager.Position = this.m_currencyManager.Count - 1;
}

private void Save_Click(object sender, System.EventArgs e)
{
DataSet changed = dataSet11.GetChanges();

if (changed == null)
return;

sqlDataAdapter1.InsertCommand.Connection.Open();
int rows = sqlDataAdapter1.Update(changed);
dataSet11.AcceptChanges();
}

"Darryn Ross" <da****@datawave.com.au> wrote in message
news:Oq**************@tk2msftngp13.phx.gbl...
Hi,

Could you supply some code showing what your doing? will make it easier if i can see what your trying to do.

Regards

Darryn

"Joe" <J_no_spam@_no_spam_Fishinbrain.com> wrote in message
news:ey**************@TK2MSFTNGP10.phx.gbl...
I have a really simple application for inserting/updating record in a

table.
The app uses a sqlConnection, sqlDataAdapter and a dataset.

I bind the fields to text boxes and a grid to allow for the

insert/editing.
I also have a button that does a Table.NewRow() and another to do the

save.
I tried using sqlDataAdapter1.Update(dataset11) but nothing seems to

change.
No new records, no errors.

I'm sure this is really easy and I'm probably just missing something here.


Nov 16 '05 #3
Joe
Any ideas?

"Joe" <J_no_spam@_no_spam_Fishinbrain.com> wrote in message
news:ey**************@TK2MSFTNGP10.phx.gbl...
I have a really simple application for inserting/updating record in a table. The app uses a sqlConnection, sqlDataAdapter and a dataset.

I bind the fields to text boxes and a grid to allow for the insert/editing. I also have a button that does a Table.NewRow() and another to do the save. I tried using sqlDataAdapter1.Update(dataset11) but nothing seems to change. No new records, no errors.

I'm sure this is really easy and I'm probably just missing something here.

Nov 16 '05 #4
Instantiate a CommandBuilder class and associate it with the sqlDataAdapter
object.
-Vish.

"Joe" wrote:
Sorry - should have posted this:

I also have a datagrid on the form which uses the same dataSet11.Tables[0]
datasource.

I actually noticed some other strange things like when I click the new
button, a new row is returned but the count for the currencyManager doesn't
increase and a new row is NOT added to the grid.
If I click on the last row in the grid and hit the down arrow to add a row,
I can enter the values but they don't get saved. If I do it again, another
row is added but when I exit a field it changes the value to null.

private void Form1_Load(object sender, System.EventArgs e)
{
sqlDataAdapter1.Fill(this.dataSet11);
sqlDataAdapter2.Fill(this.dataSet11);
BindControls(dataSet11.Tables[0] );
}

private void BindControls(DataTable table)
{
textBox1.DataBindings.Add("Text", table, "Name");
textBox2.DataBindings.Add("Text", table, "Desc");
textBox7.DataBindings.Add("Text", table, "ModelNum");

this.m_currencyManager = (CurrencyManager)this.BindingContext[table];
m_currencyManager.Position = 0;
}

private void New_Click(object sender, System.EventArgs e)
{
DataRow dr = this.dataSet11.Tables["Products"].NewRow();
dataSet11.Products.Rows.Add(dr);
m_currencyManager.Position = this.m_currencyManager.Count - 1;
}

private void Save_Click(object sender, System.EventArgs e)
{
DataSet changed = dataSet11.GetChanges();

if (changed == null)
return;

sqlDataAdapter1.InsertCommand.Connection.Open();
int rows = sqlDataAdapter1.Update(changed);
dataSet11.AcceptChanges();
}

"Darryn Ross" <da****@datawave.com.au> wrote in message
news:Oq**************@tk2msftngp13.phx.gbl...
Hi,

Could you supply some code showing what your doing? will make it easier if

i
can see what your trying to do.

Regards

Darryn

"Joe" <J_no_spam@_no_spam_Fishinbrain.com> wrote in message
news:ey**************@TK2MSFTNGP10.phx.gbl...
I have a really simple application for inserting/updating record in a

table.
The app uses a sqlConnection, sqlDataAdapter and a dataset.

I bind the fields to text boxes and a grid to allow for the

insert/editing.
I also have a button that does a Table.NewRow() and another to do the

save.
I tried using sqlDataAdapter1.Update(dataset11) but nothing seems to

change.
No new records, no errors.

I'm sure this is really easy and I'm probably just missing something here.



Nov 16 '05 #5

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

Similar topics

5
by: randy | last post by:
Hello all, I have a DataTable which I am building column by column and adding rows after each new column. The DataTable columns match the columns in my database table. I'm building the...
6
by: Andrew Cooper | last post by:
Greetings, I'm running into a little problem with a Dataadapter object. I'm using it to fill a Datatable but when I later try to Update the database using the Dataadapter.Update method, I get...
13
by: Doug Bell | last post by:
Hi, I thought I had this sorted this morning but it is still a problem. My application has a DataAccess Class. When it starts, it: Connects to a DB (OLE DB) If it connects it uses an...
11
by: Siv | last post by:
Hi, I seem to be having a problem with a DataAdapter against an Access database. My app deletes 3 records runs a da.update(dt) where dt is a data.Datatable. I then proceed to update a list to...
8
by: Zorpiedoman | last post by:
I keep getting a concurrency exception the second time I make a change and attempt to update a dataadapter. It appears this is by design, so there must be something I can do to avoid it. ...
1
by: Franklin M. Gauer III | last post by:
I create a simple DATAADAPTER in a webservice project. It creates the UPDATE, INSERT, DELETE commands for me - no problem. In vS2005 it creates these commands as RESOURCES in the RESX file (i.e....
2
by: Franklin M. Gauer III | last post by:
I create a simple DATAADAPTER in a webservice project. It creates the UPDATE, INSERT, DELETE commands for me - no problem. In vS2005 it creates these commands as RESOURCES in the RESX file (i.e....
6
by: Rich | last post by:
Dim da As New SqlDataAdapter("Select * from tbl1", conn) dim tblx As New DataTable da.Fill(tblx) '--works OK up to this point da.UpdateCommand = New SqlCommand da.UpdateCommand.Connection =...
4
by: George | last post by:
Got a question about the side effect of DataAdapter.Update() and DataTable.GetChanges(). Say I set up a DataTable and a DataAdapter in a class. Delete (Not remove) a row in the data table and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.