hi,
i'm working on windows application and sql serverCE database i write this code:

private void enregistrerBtn_Click(object sender, EventArgs e)
        {
            
            if (!exist)
            {
                
                SqlCeConnection conn = new SqlCeConnection();
                conn.ConnectionString = @" Data source= |DataDirectory|\Database1.sdf";
                try
                {
                    conn.Open();
                }
                catch (Exception ex)
                {
                   MessageBox.Show(" connexion failure");
                }
                finally
                {
                    
                    int r;
                    System.Data.SqlServerCe.SqlCeCommand cmd1 = new System.Data.SqlServerCe.SqlCeCommand ("INSERT INTO Condamne(Nom,Prenom,AnneeJugee,LieuNaissance,NomPere,NomPrenomMere,LieuResidence,SituationFamiliale,NomFrançais,PrenomFrançais)VALUES('" + nomTextBox.Text + "','" + prenomTextBox.Text + "','" + dateJugementTextBox.Text+"','"+LieuNaissanceTextBox.Text+"','"+prenomPereTextBox.Text+"','"+nomMereTextBox.Text+"','"+lieuResidenceTextBox.Text+"','"+sit uationFamilialeComboBox.Text+"','"+nomFrançaisTextBox.Text+"','"+prenomFra                  nçaisTextBox.Text+ "');", conn);
                   
                    r = cmd1.ExecuteNonQuery();
                    MessageBox.Show(" add operation success");
                   
                }
                conn.Close();
            }
            
        }

my problem is that when i execute this code the operation of inserting in the " condamne" table is successfully. but when i do an operation of search of this new person added in the table i don't find it.
i hope you can help me and execuse my bad english

Recommended Answers

All 2 Replies

To view the current record, you have to open .sdf which is located under Bin\Debug folder.

hi,
thanks for replay but i mean that when i use a ' select' query to search the record inserted i don't find it. is it that because i use DATADIRECTORY in the path of database or what?
thanks again.

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.