[Q] SqlCeDataAdapter, not updating

S

Shin

Hi,

I am having a problem updating data source through SqlCeDataAdapter
Update method.

I have a test form with a TextBox and a button. When clicking the
button [Save], a text in the TextBox should be saved in a data source
table.
I filled a DataTable using Fill method. I was able to bind one of
column in the table to a TextBox. Then I wrote a junk text on the
TextBox. I clicked [Save] button; SqlCeDataAdapter Update method is
called. I saw the column in the DataTable was updated with the new
value. BUT the value was never saved in the data source.

Have you experienced this problem? If so, is there a way to fix it?

I am using VS 2003 with freamwork version 1.1.4322.


Thanks very much for your time reading my posting.
 
S

Sebastian

Hello,

you should use the sqlCommandbuilder for the dataset and the table must have
a primary key field.
 
S

Shin

Thanks for the suggestion. I am very new to the ADO.NET technology.
So can you explain what you mean "the table must have a primary key
field?"

I created table using this SQL statement:
CREATE TABLE Test (pKey nvarchar(7) Primary Key Not Null, Field1
nvarchar(30))

I also imported schema using da.FillSchema(dt, SchemaType.Source);
where da is SqlCeDataAdapter and dt is DataTable. So dt contains a
primary key. I think Primary key is not an issue.




Sebastian said:
Hello,

you should use the sqlCommandbuilder for the dataset and the table must have
a primary key field.

Shin said:
Hi,

I am having a problem updating data source through SqlCeDataAdapter
Update method.

I have a test form with a TextBox and a button. When clicking the
button [Save], a text in the TextBox should be saved in a data source
table.
I filled a DataTable using Fill method. I was able to bind one of
column in the table to a TextBox. Then I wrote a junk text on the
TextBox. I clicked [Save] button; SqlCeDataAdapter Update method is
called. I saw the column in the DataTable was updated with the new
value. BUT the value was never saved in the data source.

Have you experienced this problem? If so, is there a way to fix it?

I am using VS 2003 with freamwork version 1.1.4322.


Thanks very much for your time reading my posting.
 
S

Sebastian

Primary Key
after filling the dataset:
ds.Tables(0PrimaryKey = New DataColumn() {ds.Tables(0)Columns(your
Primary key index or name)}

then edit the fields in your dataset and do the following:
Dim cmdBuilder as SqlCeCommandBuilder = New SqlCeCommandBuilder(your
dataadapter)
your dataAdapter.Update(dataset or table or row , optional table name)



I hope this would help.

Sebastian



Shin said:
Thanks for the suggestion. I am very new to the ADO.NET technology.
So can you explain what you mean "the table must have a primary key
field?"

I created table using this SQL statement:
CREATE TABLE Test (pKey nvarchar(7) Primary Key Not Null, Field1
nvarchar(30))

I also imported schema using da.FillSchema(dt, SchemaType.Source);
where da is SqlCeDataAdapter and dt is DataTable. So dt contains a
primary key. I think Primary key is not an issue.




"Sebastian" <[email protected]> wrote in message
Hello,

you should use the sqlCommandbuilder for the dataset and the table must have
a primary key field.

Shin said:
Hi,

I am having a problem updating data source through SqlCeDataAdapter
Update method.

I have a test form with a TextBox and a button. When clicking the
button [Save], a text in the TextBox should be saved in a data source
table.
I filled a DataTable using Fill method. I was able to bind one of
column in the table to a TextBox. Then I wrote a junk text on the
TextBox. I clicked [Save] button; SqlCeDataAdapter Update method is
called. I saw the column in the DataTable was updated with the new
value. BUT the value was never saved in the data source.

Have you experienced this problem? If so, is there a way to fix it?

I am using VS 2003 with freamwork version 1.1.4322.


Thanks very much for your time reading my posting.
 
S

Shin

Thanks again for your suggestion. I am going to try that. :)

Also, I found this:

I removed data binding thingy from that TextBox. Once I removed the
binding from it, DataAdapter Update method started working. I don't
know why... I think I need to research more about ADO.

Again, thanks for your help. I really appreciate it.


Sebastian said:
Primary Key
after filling the dataset:
ds.Tables(0PrimaryKey = New DataColumn() {ds.Tables(0)Columns(your
Primary key index or name)}

then edit the fields in your dataset and do the following:
Dim cmdBuilder as SqlCeCommandBuilder = New SqlCeCommandBuilder(your
dataadapter)
your dataAdapter.Update(dataset or table or row , optional table name)



I hope this would help.

Sebastian



Shin said:
Thanks for the suggestion. I am very new to the ADO.NET technology.
So can you explain what you mean "the table must have a primary key
field?"

I created table using this SQL statement:
CREATE TABLE Test (pKey nvarchar(7) Primary Key Not Null, Field1
nvarchar(30))

I also imported schema using da.FillSchema(dt, SchemaType.Source);
where da is SqlCeDataAdapter and dt is DataTable. So dt contains a
primary key. I think Primary key is not an issue.




"Sebastian" <[email protected]> wrote in message
Hello,

you should use the sqlCommandbuilder for the dataset and the table must have
a primary key field.

Hi,

I am having a problem updating data source through SqlCeDataAdapter
Update method.

I have a test form with a TextBox and a button. When clicking the
button [Save], a text in the TextBox should be saved in a data source
table.
I filled a DataTable using Fill method. I was able to bind one of
column in the table to a TextBox. Then I wrote a junk text on the
TextBox. I clicked [Save] button; SqlCeDataAdapter Update method is
called. I saw the column in the DataTable was updated with the new
value. BUT the value was never saved in the data source.

Have you experienced this problem? If so, is there a way to fix it?

I am using VS 2003 with freamwork version 1.1.4322.


Thanks very much for your time reading my posting.
 
S

Sebastian

No problem. We all human beings and need help. ;-)

Shin said:
Thanks again for your suggestion. I am going to try that. :)

Also, I found this:

I removed data binding thingy from that TextBox. Once I removed the
binding from it, DataAdapter Update method started working. I don't
know why... I think I need to research more about ADO.

Again, thanks for your help. I really appreciate it.


"Sebastian" <[email protected]> wrote in message
Primary Key
after filling the dataset:
ds.Tables(0PrimaryKey = New DataColumn() {ds.Tables(0)Columns(your
Primary key index or name)}

then edit the fields in your dataset and do the following:
Dim cmdBuilder as SqlCeCommandBuilder = New SqlCeCommandBuilder(your
dataadapter)
your dataAdapter.Update(dataset or table or row , optional table name)



I hope this would help.

Sebastian



Shin said:
Thanks for the suggestion. I am very new to the ADO.NET technology.
So can you explain what you mean "the table must have a primary key
field?"

I created table using this SQL statement:
CREATE TABLE Test (pKey nvarchar(7) Primary Key Not Null, Field1
nvarchar(30))

I also imported schema using da.FillSchema(dt, SchemaType.Source);
where da is SqlCeDataAdapter and dt is DataTable. So dt contains a
primary key. I think Primary key is not an issue.




"Sebastian" <[email protected]> wrote in message
Hello,

you should use the sqlCommandbuilder for the dataset and the table
must
have
a primary key field.

Hi,

I am having a problem updating data source through SqlCeDataAdapter
Update method.

I have a test form with a TextBox and a button. When clicking the
button [Save], a text in the TextBox should be saved in a data source
table.
I filled a DataTable using Fill method. I was able to bind one of
column in the table to a TextBox. Then I wrote a junk text on the
TextBox. I clicked [Save] button; SqlCeDataAdapter Update method is
called. I saw the column in the DataTable was updated with the new
value. BUT the value was never saved in the data source.

Have you experienced this problem? If so, is there a way to fix it?

I am using VS 2003 with freamwork version 1.1.4322.


Thanks very much for your time reading my posting.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top