Hy all,

I have the following problem with an update in my sdf database.I want to update a table data using a sqlceresultset.This is the code that I'm using but nothing happens.

connection.Open();
                            string sql="SELECT * FROM Table1";
                            SqlCeCommand cmd = new SqlCeCommand(sql,connection);
                            cmd.CommandType = CommandType.Text;
                            SqlCeResultSet rs= cmd.ExecuteResultSet(ResultSetOptions.Updatable|ResultSetOptions.Scrollable);

                            IEnumerator enumerator = rs.GetEnumerator();
                            bool found = enumerator.MoveNext();
                            SqlCeUpdatableRecord record;

                            if (found)
                            {
                                record = (SqlCeUpdatableRecord)enumerator.Current;
                                record.SetString(0, cui);
                                record.SetString(14, cod_asis);
                                record.SetString(1, denumire);
                                record.SetString(2, regCom);
                                record.SetString(3, adresa);
                                record.SetString(4, fax);
                                record.SetString(5, tel);
                                record.SetString(6, judet);
                                record.SetString(7, codPostal);
                                record.SetString(8, dataS);
                                record.SetString(10, tva);
                                record.SetString(11, platitorTVA);
                                record.SetString(12, "DA");
                                record.SetString(13, "DA");
                                rs.Update();
                            }
                            else
                            {
                                record = rs.CreateRecord();
                                record.SetString(0, cui);
                                record.SetString(14, cod_asis);
                                record.SetString(1, denumire);
                                record.SetString(2, regCom);
                                record.SetString(3, adresa);
                                record.SetString(4, fax);
                                record.SetString(5, tel);
                                record.SetString(6, judet);
                                record.SetString(7, codPostal);
                                record.SetString(8, dataS);
                                record.SetString(10, tva);
                                record.SetString(11, platitorTVA);
                                record.SetString(12, "DA");
                                record.SetString(13, "DA");
                                rs.Insert(record);
                            }

I need your help guys.Please:)

Recommended Answers

All 2 Replies

You need to be more clear about what you mean when you say "nothing happens". You do know that Visual Studio makes a copy of your database when you are running in Debug mode, so you won't see any changes in the original?

Yes I know that.I've resolved the issue like this:

string sql = "SELECT * FROM terti where cod_asis='" + cod_asis + "'";
                        SqlCeCommand cmd = new SqlCeCommand(sql, connection);
                        cmd.CommandType = CommandType.Text;
                        SqlCeResultSet rs = cmd.ExecuteResultSet(ResultSetOptions.Updatable | ResultSetOptions.Scrollable);
                        IEnumerator enumerator = rs.GetEnumerator();
                        bool found = enumerator.MoveNext();
                        if (found)
                        {
                            rs.ReadFirst();
                            rs.SetString(0, cui);
                            rs.SetString(14, cod_asis);
                            rs.SetString(1, denumire);
                            rs.SetString(2, regCom);
                            rs.SetString(3, adresa);
                            rs.SetString(4, fax);
                            rs.SetString(5, tel);
                            rs.SetString(6, judet);
                            rs.SetString(7, codPostal);
                            rs.SetString(8, dataS);
                            rs.SetString(10, tva);
                            rs.SetString(11, platitorTVA);
                            rs.SetString(12, "DA");
                            rs.SetString(13, "DA");
                            rs.Update();
                        }
                        connection.Dispose();
                        connection.Close();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.