SqlCeCommandBuilder

M

Mats Boberg

I can't get the command builder to build my update, insert, delete
commands... Any tips?



SqlCeDataAdapter adapter = null;

SqlCeCommandBuilder comBuilder = null;

try {

adapter = new SqlCeDataAdapter();


adapter.SelectCommand = new SqlCeCommand("select * from
tProducts",connection);

comBuilder = new SqlCeCommandBuilder(adapter);

connection.Open();


adapter.Update(productsDataSet);

} catch (Exception ex) {


throw ex;

} finally {

// check if connection is open

if( connection.State == ConnectionState.Open) {

// close connection

connection.Close();

}

}
 
W

William Ryan eMVP

Mats:

First, does your table have a PK? If not, you'll have some problems.
Second, I'm guessing that you are using a deserialized dataset....before you
call update, have you verified that the dataset has changes?
 
M

Mats Boberg

Hi William,

I the table got public key.

I'm trying to speed up a replication of the producttable through a
webservice by storing whole datasets insted of itterate through and insert
one row at a time.

So I call a webservice that returns 500 items in a dataset from the server
producttable and then I want to insert them att the sqlce producttable.

With the code below the commandbuilder doesn't build the insert, update and
delete commands.


/Mats.
 

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